We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImportArray for different data types


I’m trying to use the Cells.ImportArray method to load data into a column of a spreadsheet, but it appears that this method loads the data as text (I’m using the string[] overload). My problem is that some of the data is text, some of it is numbers. If it gets all imported as text, the formulas that are applied to some of the values then fail.

What I’d like to use is something like the built-in:

worksheet.Cells.ImportArray(inputs, 0, 0, true);

My solution to this problem at the moment is to do the looping myself and set the values directly, but I wondered if there’s a more elegant solution to this?

FYI, what I’m using instead of the above is:

for (int i = 0; i < inputs.Length; ++i)
double value;
if (double.TryParse(inputs[i], out value))
worksheet.Cells[i, 0].Value = value;
worksheet.Cells[i, 0].Value = inputs[i];



Please see the document:

I think you may try to use Cells.ImportCustomObjects() method for your needs. Please see the sub-topic / example under “Importing from Custom Objects” for your reference.

Thank you.

I’ve tried to use ImportCustomObjects, but am having a little trouble.

My method takes a list of strings, so to use ImportCustomObjects I need to create a class which I can pass in. So I have tried the following:

var list = inputs.Select(i => new { Value = i }).ToList();

worksheet.Cells.ImportCustomObjects(list, new[] { “Value” }, false, 0, 0, list.Count, true, “dd/mm/yyyy”, true);

This sort of works, but I’ve had to set “Insert Rows” to true (which obviously inserts new rows, rather than updating what’s already there). If I set “Insert Rows” to false, nothing seems to happen. Is this the correct behaviour?


Not to worry looks like I’ve got it working, not sure why it wasn’t working before.


Thanks for your posting and using Aspose.Cells.

We are glad to know that your issue is resolved. If you face any other issue, please feel free to post, we will be pleased to help you further.