The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Sridhar_M
2 years agoContributor
Is it possible to use spreadsheet component (Table View in it) in the Book ?
Hi All,
I create a spreadsheet business rule to refresh the data from external table using Table Views, now our users wants to drop these files into OneStream file share on daily basis so external systems can consume.
Is it possible to use parcel service to refresh these files (using table views with in the spreadsheet) and drop them into file share every time the job trigger ?
Or Is there any alternate approaches to export data from custom table to excel files ?
Thank you.
There are 3 approaches I am aware of, via standard Data Management features:
- Build your view as a Grid View powered by a Data Adapter, put it in a Dashboard, then use a DM Step of type "Export Report" pointing to the dashboard.
- Use a DM Step of type "Export File", and configure your Excel file with Extensible Document features. The job has an option to process them.
- Use a DM Step of type "Execute Business Rule", and just produce an Excel file in code.
Then you can probably use Parcel Service to send out the resulting output, but I'm not very familiar with it myself.
6 Replies
- JackLacava
OneStream Employee
There are 3 approaches I am aware of, via standard Data Management features:
- Build your view as a Grid View powered by a Data Adapter, put it in a Dashboard, then use a DM Step of type "Export Report" pointing to the dashboard.
- Use a DM Step of type "Export File", and configure your Excel file with Extensible Document features. The job has an option to process them.
- Use a DM Step of type "Execute Business Rule", and just produce an Excel file in code.
Then you can probably use Parcel Service to send out the resulting output, but I'm not very familiar with it myself.
- Sridhar_MContributor
Thank you JackLacava for providing those details.
I tried all 3 steps, 2nd and 3rd is working. But for the 1st step if I try to export using DM step with SQL Table Editor/Grid View components with in dashboard, it is just exporting empty file with out data.
Thank you.
Sridhar
- MarkBirdContributor III
Hi Sridhar
We're having a similar issue. Did you manage to resolve this?
Regards,
Mark
- Sridhar_MContributor
Hi jwagner
Here’s a code snippet that generates an Excel file, with the DataTable passed as an argument to the function.#Region "Create Excel File"Public Sub CreateExcelFileFromDataTable(ByVal si As SessionInfo, dataTable As DataTable)'Create a new Excel fileDim filePath As String = "\\FolderPath\"FileName".xlsx"BRApi.ErrorLog.LogMessage(si,filePath & dataTable.Rows.Count)'Create the SpreadsheetDocument object and set its type to WorkbookUsing document As SpreadsheetDocument = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook)'Create the workbookDim workbookPart As WorkbookPart = document.AddWorkbookPart()workbookPart.Workbook = New Workbook()'Create the worksheetDim worksheetPart As WorksheetPart = workbookPart.AddNewPart(Of WorksheetPart)()worksheetPart.Worksheet = New Worksheet()'Create the sheet dataDim sheetData As SheetData = worksheetPart.Worksheet.AppendChild(New SheetData())'Create the header rowDim headerRow As Row = New Row()'Loop through each column in the DataTable and add it to the header rowFor Each column As DataColumn In dataTable.ColumnsheaderRow.AppendChild(New Cell() With {.DataType = CellValues.String, .CellValue = New CellValue(column.ColumnName)})Next'Add the header row to the sheet datasheetData.AppendChild(headerRow)'Populate the data rowsFor Each dataRow As DataRow In dataTable.RowsDim row As New Row()'Loop through each column in the DataTable and add the corresponding cell value to the current rowFor Each column As DataColumn In dataTable.ColumnsDim cellValue As String = dataRow(column.ColumnName).ToString()Dim cell As New Cell()' Check the data type and set the cell data type accordinglyIf column.DataType Is GetType(Integer) OrElse column.DataType Is GetType(Long) OrElse column.DataType Is GetType(Double) OrElse column.DataType Is GetType(Decimal) Then' Handle numeric typesIf Not String.IsNullOrEmpty(cellValue) Thencell.DataType = CellValues.Numbercell.CellValue = New CellValue(cellValue)Else' Handle empty numeric cells as blankcell.DataType = CellValues.Numbercell.CellValue = New CellValue("0")End IfElseIf column.DataType Is GetType(DateTime) Then' Handle DateTime typesDim dateValue As DateTimeIf DateTime.TryParse(cellValue, dateValue) Thencell.DataType = CellValues.Datecell.CellValue = New CellValue(dateValue.ToString("yyyy-MM-ddTHH:mm:ss"))Elsecell.DataType = CellValues.Stringcell.CellValue = New CellValue("")End IfElse' Default to string for all other data typescell.DataType = CellValues.Stringcell.CellValue = New CellValue(cellValue)End Ifrow.AppendChild(cell)Next'Add the row to the sheet datasheetData.AppendChild(row)Next'Create the sheetsDim sheets As Sheets = workbookPart.Workbook.AppendChild(New Sheets())Dim sheet As Sheet = New Sheet() With {.Id = workbookPart.GetIdOfPart(worksheetPart), .SheetId = 1, .Name = "Data"}sheets.Append(sheet)'Save changesworkbookPart.Workbook.Save()End UsingEnd Sub#End Region
Related Content
- 2 months ago
- 4 months ago
- 7 months ago
- 2 years ago
- 1 year ago