Issue with ConvertNumericData for data like "64:60"

Hi Aspose.cells support,

We want to extract from a CSV file (using Aspose.cells.7.3.1) data as string. So we put the ConvertNumericData to false.
It works well for integer data like “12”, and for data like “<span style=“font-size:9.0pt;mso-bidi-font-size:
12.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:“Times New Roman”;
mso-ansi-language:EN-US;mso-fareast-language:FR;mso-bidi-language:AR-SA” lang=“EN-US”>74:70” and “<span style=“font-size:9.0pt;mso-bidi-font-size:
12.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:“Times New Roman”;
mso-ansi-language:EN-US;mso-fareast-language:FR;mso-bidi-language:AR-SA” lang=“EN-US”>69:65” it works too. But for “<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:DoNotShowComments/>
<w:DoNotShowPropertyChanges/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>FR</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val=”–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><span style=“font-size:9.0pt;mso-bidi-font-size:
12.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:“Times New Roman”;
mso-ansi-language:EN-US;mso-fareast-language:FR;mso-bidi-language:AR-SA” lang=“EN-US”>64:60<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>", it returns an Aspose.cells.DateTime. So why the last data is not considered as a string?

Code used to set ConvertNumericData to false :

LoadOptions lo = new LoadOptions(FileFormatType.CSV);
lo.setConvertNumericData(false);
lo.setLocale(Locale.ENGLISH);

try {

workbook = new Workbook(csvPath, lo);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

Code used to get the cell vallue :
Cell currentCell = sheetCells.get(row, cellInd);
Object cellValue = currentCell.getValue();
N.B: I join 3 attachments.
Template.rtf : is the desired result.
CSVTested.csv : is the csv file where the data are extracted
Result.rtf : is the current result

Cordially.
jplim.

Hi,

Thanks for using Aspose.Cells for Java.

Please download and use the latest version:
Aspose.Cells
for Java v7.3.2.1



Please use the following method to stop converting any string into date.

TxtLoadOptions.setConvertDateTimeData(false);

I have tested your file with the latest version using the following code and it works fine. Please see the output at the bottom of this post.

Java


TxtLoadOptions lo = new TxtLoadOptions(FileFormatType.CSV);

lo.setConvertNumericData(false);

lo.setConvertDateTimeData(false);

lo.setLocale(Locale.ENGLISH);


Workbook workbook = new Workbook(“F:\Shak-Data-RW\Downloads\CSVTested.csv”, lo);


Worksheet worksheet = workbook.getWorksheets().get(0);


Cell currentCell = worksheet.getCells().get(“A5”);

String cellValue = currentCell.getStringValue();


System.out.println(cellValue);


Output:
64:60

Thanks for your quickly response. It works well now. But what is the difference between the two objects “LoadOptions” and “TxtLoadOptions”?

Hi,

Thanks for your question.

LoadOptions is a base class of some derived classes. TxtLoadOptions is the child class of it, which specifically deals with the text based formats like csv.

So each TxtLoadOptions is an object of LoadOptions too.

Hi,
Okay i understand better now.
Thanks for your reply.

Hi,

Thanks for your understanding and using Aspose.Cells.

Let us know if you face any other issue relating to Aspose.Cells, we will be glad to assist you.