Aspose cells java - importCSV throws exception string value cannot exceed 255

Hi,

We are using aspose cells java 19.3 jar for merging CSV files to excel base template.
Below is sample source code. It is throwing exception in importCSV() method saying data exceeds cell limit.

We see the same issue with the latest 19.10 jar also.

public void mergeCsv(final String csvFilePath, final String sheetName, final String delimiter,
final String cellAddress) throws Exception {

	// If target sheet does not already exist, create it and hide it. This follows SCC's behavior.
	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();	// Must use TxtLoadOptions for locale to be considered.
	//options.setLocale(locale);

	
	options.setSeparatorString(delimiter);
	options.setLoadStyleStrategy(TxtLoadStyleStrategy.NONE);	// Obey existing cells' formatting.
	options.setHasFormula(true);	// Treat values starting with "=" as formulas (PS#13393).

	
	// Import from CSV file.
	cells.importCSV(csvFilePath, options, row, column);

	
}

Below is the exception thrown from aspose.

[3:55 PM] Chetana Rupa Bhandaru
com.aspose.cells.CellsException: “string value cannot exceed 255 characters”("Based on cell "Sheet1!T2)
at com.aspose.cells.zaco.c(Unknown Source)
at com.aspose.cells.zaco.c(Unknown Source)
at com.aspose.cells.zaem.y(Unknown Source)
at com.aspose.cells.zaem.a(Unknown Source)
at com.aspose.cells.zaem.b(Unknown Source)
at com.aspose.cells.zaem.k(Unknown Source)
at com.aspose.cells.zcfo.a(Unknown Source)
at com.aspose.cells.zcfo.a(Unknown Source)
at com.aspose.cells.zcfo.a(Unknown Source)
at com.aspose.cells.zcfo.a(Unknown Source)
at com.aspose.cells.Cells.importCSV(Unknown Source)
at testApplication.TestMyApp.mergeCsv(TestMyApp.java:58)
at testApplication.TestMyApp.main(TestMyApp.java:24)

Sample code and excel and CSV files that we merged are attached.
Please check this and let us know if you need any more information to debug it.

ThanksimportCSVSample.zip (7.2 KB)

@PrasunaKota,

Thanks for the template file and sample code.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with template file. I found Cells.importCSV throws exception “string value cannot exceed 255 characters…”. I have logged a ticket with an id “CELLSJAVA-43041” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@PrasunaKota,
It’s limitation of MS Excel that the length of string in the formula must be less then 255. So we will ignore such kind of incorrect formula (keep the formula expression as plain string value of corresponding cell) in later fix/versions to avoid the Exception.

@PrasunaKota,

Please try our latest version/fix: Aspose.Cells for Java v19.10.3(attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose_Cells_Java_v19.10.3.zip (6.6 MB)

The issues you have found earlier (filed as CELLSJAVA-43041) have been fixed in Aspose.Cells for Java v19.11. This message was posted using Bugs notification tool by ahsaniqbalsidiqui