Problems with SmarMarker VariableArray


Using the evaluation version of Aspose.Cells I am having some troubles with smart markers.

Both single variable and datasource markers work like a charm. however array markers dont seem to work. Here is the code + marker contained in the excel file:

String[] arr = new String[2];
arr[0] = “foo”;
arr[1] = “bar”;
designer.SetDataSource(“test”, arr);

The marker in the excel file is: &=$test

When I run this nothing is replaced in the excel file. I have also tried with:

This replaces the marker with white space.

Any help appriciated.

- Andrew


Hi Andrew,

Thanks for your report.

Yes, this is a bug. I fixed it in the attached version. Please try it.


Thank you for the quick reply.

The version you sent me works. I.e. by adding &=$VariableArray to a field it will fill successive rows with data from the array.

Is a there a way or any plans to implement a way where you can have a dataset or array fill a variable number of columns instead of rows?

This would be very helpful in my case since I am displaying a table of data where my dataset has a variable number of columns.




Hi Andrew,

If your dataset has variable number of columns that cannot be determined when you create the designer template, you can create the smart markers at run time.

For example:

Workbook workbook = workbookDesigner.Workbook;

DataTable dt = dataset.Tables["Table1"];

for(int i = 0; i < dt.Columns.Count; i ++)

workbook.Worksheets[0].Cells[0, i].PutValue("&=Table1." + dt.ColumnsIdea [I].ColumnName);




Yep that works. However this requires a programmer :slight_smile:

On another note, setting the background color for a cell does not seem to work?

worksheet.Cells[“A1”].Style.BackgroundColor = Color.Yellow;

- Andrew



I found another issue with setting the Style.Number for a Cell. Here is the code I am using for setting the Background color and Style.Number, none of which seem to work:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Name = “Report”;

worksheet.Cells[“A1”].Style.BackgroundColor = Color.Yellow;
worksheet.Cells[“A2”].Style.Number = 2;

workbook.Save(“C:\test.xls”, FileFormatType.Default);

Please advise.

- Andrew


Hi Andrew,

Please change your code to:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "Report";

//For background settings, please check

worksheet.Cells["A1"].Style.ForegroundColor = Color.Yellow;

worksheet.Cells["A1"].Style.Pattern = BackgroundType.Solid;

//Number format only applies to numeric value, not string value


// or you can change it to:

//worksheet.Cells["A2"].PutValue("100.00", true);

worksheet.Cells["A2"].Style.Number = 2;

workbook.Save("C:\\test.xls", FileFormatType.Default);

To import dynamic columns of data, I think you may have to write a few lines of code to get the flexibility.