Free Support Forum - aspose.com

Issue with CSV Merge in Portuguese settings:

How to reproduce?
Case1: System local settings: Portuguese brazil
Merge CSV file with numeric data, -> CSV data is showing as String format,

Cse2: System local settings: English
Merge CSV file with numeric data, -> CSV data is showing as numeric format,
and this is the expected behavior.

      // Sample Code:
      final Worksheet sheet = getSheet(sheetName, false);
	final Cells cells = sheet.getCells();
	// Mitigates OutOfMemoryError.
	cells.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
	// Find row and column to insert into.
	final int[] rowColumn = CellsHelper.cellNameToIndex(cellAddress);
	final int row = rowColumn[0];
	final int column = rowColumn[1];

	// Prepare for CSV import.
	final TxtLoadOptions options = new TxtLoadOptions();	
	//options.setLocale("en-us");
	
	options.setSeparatorString(delimiter);
	options.setLoadStyleStrategy(TxtLoadStyleStrategy.NONE);	// Obey existing cells' formatting.
	options.setHasFormula(false);	 
	// Import from CSV file.
	cells.importCSV(csvFilePath, options, row, column);

Attached is the sample CSV file Downloads.zip (261.2 KB)

@PrasunaKota,
I have tried to execute the sample code by setting the missing values to a possible set of values but could not reproduce this issue. Could you please share a runnable complete console application (all properties and values are set like sheetName, cellAddress etc. in above sample code) which can be used to reproduce the issue here. Also, share the exact system settings which you have done for testing the issue in both the locale settings. We will use this information to reproduce the issue and provide assistance at the earliest.

Attached the sample code along with CSV file and template file to merge. I have also given the out put files for both working [en-us] and non working [brazil] local
asposeLocalIssue.zip (1.2 MB)

@PrasunaKota,
We need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43054 - Issue with CSV Merge in Portuguese settings

Thanks for acknowledgment . We will be waiting for your response.

As its a blocker for our users, request you to update the ETA ASAP

@PrasunaKota,
For locale Portuguese or Brazil, the default decimal separator is ‘,’ instead of ‘.’, so those numeric values with decimal separator ‘.’ should not be parsed or may be parsed to unexpected value for user.

The dataset is large for your case and we don’t know which specific value was not parsed. If you are not referring to those we found (with separator ‘.’), please point out the specific cell and we will make further investigation.

Hi

Please refer SWDATA sheet from cell CC52.
.
Its not about the separator, the value is imported as string instead of numeric.

Can we have call on this, Ill show the issue for speeding up the investigation?
Note: Its a blocker P1 issue for our customer. We would need solution asap. Thanks for understanding.

@PrasunaKota,
Thank you for the feedback. We have recorded it with the ticket and will analyse it soon.

@PrasunaKota,
The original value in csv of CC52 is “14.285714001”. If you require, we may support to parse it as numeric value but the parsed value for this cell will become 14285714001 because for Portuguese Brazil it is 14285714001 infact. If it is not the expected result for you, for example, you want to get the same result with en-US locale, then you should specify the Region or Locale as en-US for the LoadOptions when loading the CSV file.

Hi,

Thanks for the response.
The concern here is about the cell type after importing.
We are always setting locale to ‘en_US’ in load options ,irrespective of user system locale . But it is behaving differently when user system locale is Brazil. The cell type is becoming string instead if numeric.

@PrasunaKota,
We are analysing your concern and will share our feedback soon.

@PrasunaKota,
We found the issue for your situation. When importing CSV data into existing workbook, the used locale is not the one specified by TxtLoadOptions but the one of the existing workbook. We will fix this bug soon. As workaround, with current version you may set the locale of the Workbook as en_US and then importing the CSV data.

thank you

Workaround worked. Hope this will not have any other side effects

@PrasunaKota,

Good to know that the workaround fixes your issue now. This won’t affect, so you may use the devised approach. Also, we will fix it and provide you the fixed version soon.

@PrasunaKota,

Please try our latest version/fix: Aspose.Cells for .NET v19.11.7 (attached)
aspose-cells-19.11.7.zip (6.7 MB)
Your issue should be fixed in it.

Let us know your feedback.