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

Free Support Forum - aspose.com

TxtLoadOptions setConvertNumericData() and setKeepExactFormat() for certain columns only

Suppose I have a tab-delimited file like this:

0000000001 Product One 01.10
0002.1 Product Two 02.2
P3 Product Three 03.330
0e4 Product Four 04
0005 Product Five 05
6.12345678901234567890 Product Six 06

The above file is imported using importCSV().

I’d like the first column to appear exactly as is.
I’d like the last column to be parsed as numbers.

Is this possible? I can sort of achieve half of what I want using setConvertNumericData() and setKeepExactFormat(), but they apply to the whole data set and I need them to be for certain columns only.

Code I have so far:

final Workbook workbook = new Workbook();
workbook.getSettings().setLocale(new Locale(“en”, “US”)); // Numbers in file are in en_US format.

final TxtLoadOptions options = new TxtLoadOptions();
sheet.getCells().importCSV(“C:\Temp\products.txt”, options, 0, 0);


Thanks for providing us some details.

We think for your requirements, you can use
load option TxtLoadOptions.PreferredParsers. Please see the example in the post:


Hope, this helps you a bit.

Thank you.

Thanks Amjad. Using custom parsers yield the desired results.

Hi Simon,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the custom parsers. Let us know if you encounter any other issue, we will be glad to look into it and help you further.