Numberformat is erased after ImportTwoDimensionArray

Hi,


The following code resets the CultureCustom NumberFormat of the first cell to null:

var wb1 = new Workbook(“NumberFormat.xlsx”);
var ws = wb1.Worksheets[0];
object[,] arr = { { “0.01” } };
var cells = ws.Cells;

var format = cells[0, 0].GetStyle().CultureCustom; // “#,##0_);(#,##0)”
ws.Cells.ImportTwoDimensionArray(arr, 0, 0, true);
var newFormat = cells[0, 0].GetStyle().CultureCustom; // null

This only happens for some number formats; others are correctly kept.

Importing an array should not set the numberformat to null.


Best regards.

Hi,


Thanks for your template file and sample code.

Well, I think you may try to use respective overloaded version of Cells.ImportTwoDimensionArray() method that contains TxtLoadOptions as paramter, so you could set your desired attributes accordingly for your needs, see the updated sample code below that works as expected.
e.g
Sample code:

var wb1 = new Workbook(“e:\test2\NumberFormat.xlsx”);
var ws = wb1.Worksheets[0];
object[,] arr = { { “0.01” } };
var cells = ws.Cells;

TxtLoadOptions options = new TxtLoadOptions();
options.ConvertNumericData = true;
options.KeepExactFormat = true;

var format = cells[0, 0].GetStyle().CultureCustom; // “#,##0_);(#,##0)”
ws.Cells.ImportTwoDimensionArray(arr, null, 0, 0, options);
var newFormat = cells[0, 0].GetStyle().CultureCustom; // null

Hope, this helps you a bit.

Thank you.

Hi,


Thank you but this does not work either.

newFormat is “0.##” in that case.

As I said, the formats are not always overwritten, they are overwritten in my example case though, so it seems like a bug.


Best regards.

Hi,


We will get back to you shortly.

Thank you.

Hi John,


We have logged an investigative ticket CELLSNET-43361 to look further into this matter. Please spare us little time to properly analyze your presented scenario to assist you further in this regard. In the meanwhile, we will keep you posted with updates in this regard.

Hi,

Please try our latest version/fix: Aspose.Cells for .NET v8.3.2.3

We have fixed your issue now.

Let us know your feedback.

Thanks,

The issues you have found earlier (filed as CELLSNET-43361) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.