Aspose markers are shown in the excel file that is generated using WorkbookDesigner class

I am in the process of evaluating Aspose.Cells and ran in to few issues that I have listed below. Please clarify.

1. I am using WorkbookDesigner class for generating an Excel file. Aspose markers are predefined in an Excel file. When a datatable/Dataset(with some data) is assigned as a datasource, Excel is generated fine with some rows populated in it. This piece is working good.

However When the datatable/Dataset(with no data) is assigned as a datasource, Excel file is generated with markers showing on the report. I am using WorkbookDesigner.SetDataSource(dtDataTable). dtDataTable does not contain any rows. I would expect the excel to be generated without any markers in it.

2. Is there any default row/ column alignements when WorkbookDesigner.SetDataSource is used. I see that some columns are left aligned and some columns are right aligned.

FYI..I have used the below code for both of the above issues.

Dim oWorkbookDesigner As WorkbookDesigner = New WorkbookDesigner
oWorkbookDesigner.Workbook = New Workbook(Path.Combine(Lookup.GetFilePath(Enums.PathName.ExcelDocumentTemplates, Date.Now), strTemplateFileName))

If dsDataSource IsNot Nothing AndAlso dsDataSource.Tables.Count > 0 Then
For Each dtDataTable As DataTable In dsDataSource.Tables
oWorkbookDesigner.SetDataSource(dtDataTable)
Next
oWorkbookDesigner.Process(True)
oWorkbookDesigner.Workbook.Save(strOutPutPath)
End If
oWorkbookDesigner = Nothing
If eSaveDocType = Enums.SaveDocumentType.Display Then
CommonUIUtils.OpenPreDefinedExtensionFile(strOutPutPath)
End If

Hi,


1) Please set isPreserved parameter in Workbook.Desiger() method to “False”, it will suit your need, e.g you may update your line of code:
oWorkbookDesigner.Process(True)
to:
oWorkbookDesigner.Process(False)

Also, I tested with my sample template file using the following code. The output markers are disappeared when there is no data in the source data table.

Sample code:

Dim designer As New WorkbookDesigner()
Dim workbook As New Workbook(“e:\test2\SmartMarkers.xlsx”)
designer.Workbook = workbook

Dim dt1 As DataTable = Create_ValidTable()

designer.SetDataSource(“Investment”, dt1.DefaultView)

designer.Process(False)

Dim output As String = “e:\test2\out__SmartMarkers_result.xlsx”
workbook.Save(output)

Private Function Create_ValidTable() As DataTable
Dim dt As New DataTable(“Table 1”)
dt.Columns.Add(“Id”, GetType(String))
Return dt
End Function


2) Well, it depends on the markers cells (where you place the smart markers in the template file) alignment setting + formatting applied etc., if it is left aligned, the processed data would be left aligned too in the cells. Also, if there is valid numeric data in a column, it will be right aligned. If there is string data in a column, it will left aligned.


Thank you.