1

ここで、Spotfire Automation Services で DataTable を Xlsx にエクスポートするための Automation Service を作成しようとした人がいるかどうか疑問に思っていましたか? 作成しようとしていますが、問題があります。誰かがこれを行うことができたら、あなたのプロジェクトを共有してもらえますか?

これは私がこれまでに持っているコードですが、DataSource と DataTable へのアクセスに問題があります。

    protected override TaskExecutionStatus ExecuteCore(TaskExecutionContext context)
    {
        DataRowReader dataRowReader;
        ///Create a DataWriter
        DataWriter writer = context.Application.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter);
        ///<summary>
        ///Call the DataWriter Core from here or call a class that will do the relevant work
        ///<toDO>Need to find a way to access the current DataTable of the Open Analysis</toDo>
        ///</summary>
        Document doc = context.Application.Document;
        if(doc == null)
            return new TaskExecutionStatus(false, "NoAnalysisLoaded");

        DataManager data = doc.Context.GetService<DataManager>();

        DataTable table = data.Tables.Add(doc.ActiveDataTableReference, dataSource);


        string fileName = context.ExpandTags(this.filePath);
        FileStream fs = File.OpenWrite(fileName);
        //See how to properly impliment the writers
        writer.Write(fs, table, new IndexSet(table.RowCount, true), table.Columns.Names);

        fs.Close();
        data.Tables.Remove(table);
        return new TaskExecutionStatus(true);
    }
4

1 に答える 1