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();
options.setSeparator(’\t’);options.setConvertNumericData(false);options.setKeepExactFormat(false);
sheet.getCells().importCSV(“C:\Temp\products.txt”, options, 0, 0);workbook.save(“C:\Temp\dataTypeTest.xlsx”);