0

I have search around the web but could not find any solution. I have a Excel file used as a template, with a area to parse data from DB. Among the columns of the Excel file, there is a number column with a custom format. My code (C#) of setting data to Excel file is as below:

Aspose.Cells.Worksheet ws;
Aspose.Cells.Range rg;
...
rg = ws.Cells.CreateRange("A1", "M10");
var setData = genDataArray(dt); //this function convert Datatable to 2D object array
rg.Value = setData;

Another attempt is also a failure:

ws.Cells.ImportDataTable(dt, false, "A1");

The code works fine. Data is set correctly to the Excel file, but without any format of the Excel file.

When I click the cells of Excel file (after the process), and press Enter, the value is formatted with the style I previously set in the Excel file.

How can i make the Aspose to apply the format I set in the Excel file?

Thank in advance.

N.D.H.Vu
  • 127
  • 1
  • 16

1 Answers1

1

After varous attempts, I finally found an solution.

The number column of inputted DataTable have data type of String, so i guess Aspose set it to the Excel file as Text value.

After changing it to Decimal type, the value is correctly formatted.

N.D.H.Vu
  • 127
  • 1
  • 16