Free Support Forum - aspose.com

Smart Marker Not Converting to Numeric

I am using Aspose.Cells version 7.0.2.0. It appears the the smart marker does not convert an String value from a .Net DataTable to numeric value in Excel when I use the decorator, “numeric”. An older version of Aspose.Cells that I was using does not have this problem.

For example, if I add a column to a DataTable
dataTable.columns.add(“testColumn”)
dim newRow as DataRow = dataTable.newRow()
newRow(“testColumn”) = 0.25

and then use the following smartMarker: in my Excel template:
&=dataTable.testColumn(numeric)

The value, 0.25, does not show up as numeric in Excel.

The numeric decorator is a very useful feature. Because we often we have to “N/A” and numbers or percentages in a data column.

Hi,


I have tested your scenario with v7.0.2, it works fine. See the sample code and find attached the input and output files.

Sample code:

//…

WorkbookDesigner designer = new WorkbookDesigner();
Workbook workbook = new Workbook(“e:\test2\Num_SmartMarkers.xlsx”);
designer.Workbook = workbook;

DataTable dt1 = Create_ValidTable1();
DataTable dt2 = CreateValidTable2();

designer.SetDataSource(“dataTable”, dt1.DefaultView);
designer.Process(true);

string output = “e:\test2\outNum_SmartMarkers_result.xlsx”;
workbook.Save(output);
//…

private DataTable Create_ValidTable1()
{
DataTable dt = new DataTable(“dataTable”);
dt.Columns.Add(“testColumn”);
dt.Rows.Add(“0.25”);
return dt;
}


In the output file, there is no green triangle with “0.25” value to show that numbers stored as text.
If you find the issue, let us know with sample code and template files.

Thank you.

I am not sure if I misunderstand something here.

I downloaded your attached file, outNum_SmartMarkers_result.xlsx. In sheet1, Cell A1, I DO see 0.25 with a little green triangle on the upper left corner. When I format the column A to percentage, the cell value remain to show 0.25 and not a % I think because it is not numeric. Do you really not see the little green triangle ???

Would you download the file from this forum and double check?

Thanks very much.

Hi,

I can see the problem (green triangle) using Ms-Excel 2010 and 2007. I think, it is a bug of Aspose.Cells.

We will look into it and fix it asap.

I have tested it using the latest version:
Aspose.Cells for .NET v7.0.2

Below is my sample code for a reference and the output file.

This issue has been logged as CELLSNET-40019.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\Num_SmartMarkers.xlsx”;


DataTable dt = new DataTable(“dataTable”);

dt.Columns.Add(“testColumn”);

dt.Rows.Add(“0.25”);


WorkbookDesigner designer = new WorkbookDesigner();

Workbook workbook = new Workbook(filePath);

designer.Workbook = workbook;


designer.SetDataSource(dt);

designer.Process(true);


workbook.Save(filePath + “.out.xlsx”);

Hi,



Please try our latest fixed version v7.0.2.2, we have fixed your issue.


Thank you.