We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to remove smart markers when data table is empty

I am using your Smart Marker feature to inject data into an Excel template. Everything works well except when the data table returned from the stored procedure is empty; in this case the bare smart markers are left in the Excel report. Ideally, if the data set or table is empty, the smart markers are automatically removed leaving the report empty. Even if I call the process method like this: WorkbookDesigner.Process(False)

the “False” parameter will not make the smart markers go away. Is there an easy way to not have the markers show up in the final excel workbook when I have an empty data table that I am passing to Excel? Thanks.

Dim excelTemplate As String = “template.xls”



I think you might be using some older version of Aspose.Cells for .NET as the feature is already supported in the latest versions of Aspose.Cells for .NET. Please try the attached version.

Following is my testing code which works fine, the smart maker(s) are removed in the generated file if the datatable is empty.

Sample code:

Dim dt As New DataTable("MyData")
dt.Columns.Add(New DataColumn("MyField", GetType(String)))

'Dim dr As DataRow = dt.NewRow()
dr("MyField") = "1"
dr = dt.NewRow()
'dr("MyField") = "2"
'dr = dt.NewRow()
dr("MyField") = "3"

Dim designer As New WorkbookDesigner()
designer.Workbook.ConvertNumericData = True
designer.Save("f:\test\out_msm1.xls", FileFormatType.Default)
The output file is also attached.
Thank you.