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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.