Python Smartmarker Report - table of data source not documented

We already use Aspose.cells Smartmarkers via .net but would like to see if we can use via Python (I know it’s a separate license). I’m trying to merge a table of data into a template but can only merge a column or single row ie. below code for single column.

cdf=wb.cells_data_table_factory
df=cdf.get_instance([“2”,4],[“col1”])
df=datatable
designer.set_data_source(“Test”,df)

There are no examples that I can find of this in the documentation - only this page Smartly importing and placing data with Smart markers in Python via .Net|Documentation

Please could you provide a small code snippet for this.

@mcunningham,

Yes, currently, in the Docs there is one example of simple smart markers with variables and simple arrays. Could you please share complete (runnable) sample code that you are using to show the issue. Also, share your template Excel file (containing Smart Markers) and your current output Excel file (via Aspose.Cells for Python via .NET). Also, share your expected Excel file. We will check it soon.

Thanks for the quick response. Code below. I’m building a simple template on the fly.

import aspose.cells
from aspose.cells import License, Workbook, FileFormatType, WorkbookDesigner, ICellsDataTable
import io

Instantiating a WorkbookDesigner object

designer = WorkbookDesigner()

Set a Workbook for the WorkbookDesigner

wb = Workbook()
designer.workbook = wb

Input some markers to the cells.

cell3=wb.worksheets.get(0).cells.get(0, 0)
cell3.value = “&=Test.col1”
cell3=wb.worksheets.get(0).cells.get(0, 1)
cell3.value = “&=Test.col2”

cdf=wb.cells_data_table_factory

Works for a row of data

#df=cdf.get_instance([2,4],["col1,“col2”])

And a column

df=cdf.get_instance([2,4],[“col1”])

But how do I do for a table with multiple rows of data?

designer.set_data_source(“Test”,df)
designer.process(0,True)

Save the Output file to check.

wb.save("/tmp/SmartMarkerOutput.xlsx")

@mcunningham,

Thanks for providing further details.

We will check and may provide sample code on using Smart Markers based on data table as source using Aspose.Cells for Python via .NET. We have opened the following new ticket(s) in our internal issue tracking system.

Issue ID(s): CELLSPYTHONNET-128

Once there is an update on it, we will let you know.

Thanks Amjad,

Looking forward to it.

Mike.

@mcunningham,

You are welcome.

@mcunningham,

We evaluated your requirements. We are afraid, currently, the two-dimensional array is not supported in Aspose.Cells for Python via .NET API. So, the function like “GetInstance(int[,] vals)” in .NET is not present in Python API. We will support it.

Once we have any information available, we will let you know.

@mcunningham
HI! There is alternative way to realize it you can try the following code.

import aspose.cells
from aspose.cells import License, Workbook, FileFormatType, WorkbookDesigner, ICellsDataTable,CellsDataTableFactory
import io

designer = WorkbookDesigner()
# Set a Workbook for the WorkbookDesigner
wb = Workbook()
designer.workbook = wb
# Input some markers to the cells.
cell3=wb.worksheets.get(0).cells.get(0, 0)
cell3.value = "&=$col1"
cell3=wb.worksheets.get(0).cells.get(0, 1)
cell3.value = "&=$col2"
# data for column1
val1 = [1, 2, 3]
# data for column2
val2 = [11, 22, 33]
# Set data for column1 and column2
designer.set_data_source("col1", val1)
designer.set_data_source("col2", val2)
designer.process(0, True)
# Save the Output file to check.
wb.save("/tmp/SmartMarkerOutput.xlsx")

Hope helps a bit!