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)