Build 4.5.0.4 of xlsgen adds support for custom data mapping when importing data from CSV, HTML, JSON and XML files.
If you know in advance that in column 2 of your file, there's data of the form
152 kms, where kms is short for kilometers, xlsgen will by default import the data as a string and as a result it will not be possible to make numeric calculations on this column without first translating strings into numbers.
Beginning with this build, with the introduction of the
ColumnDataMappingFormatByIndex property, you can specify a custom data mapping, before importing the file, which takes care of this and as a result imports the data as numbers with the appropriate number format. The consequence is that any calculation can be triggered right after the import phase process without manual changes.
Here is an example of source code, for an HTML file, but this works equally well for CSV, HTML, JSON and XML files :
xlsgen::IXlsWorkbookPtr wbk = engine->New( L"output.xlsx" );
xlsgen::IXlsWorksheetPtr wksht = wbk->AddWorksheet( L"Sheet1" );
wksht->Import->HTML->Options->ColumnDataMappingFormatByIndex[3] = L"0 \"kms\""; // note the use of double-quotes
wksht->Import->HTML->ImportFile(L"input\\data.html");
wbk->Close();
There is hope that in the course of 2018, pattern recognition, some form of AI, will be added so that xlsgen can figure out those patterns alone, so automatic type inference will be more powerful. It has already been improved in xlsgen 4.5