When trying to read a excel file the text coming as like below
V e n d o r N u m b e r
This is the expected output - Vendor Number
This is the code we use to extract the excel file
LoadOptions loadOptions = new LoadOptions(LoadFormat.AUTO);|
FileFormatInfo finfo = FileFormatUtil.detectFileFormat(fileName);|
if (finfo.getFileFormatType() == FileFormatType.UNKNOWN)|
{|
loadOptions = new TxtLoadOptions(LoadFormat.TAB_DELIMITED);|
}|
loadOptions.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);|
Workbook w = new Workbook(fileName,loadOptions);|
Please suggest to get the word without any spacing between the characters
Please notice, I am able to reproduce the issue as you mentioned by using the following sample code with your template file. I found Aspose.Cells is giving space separated characters when reading from a Tab Delimited file:
e.g. Sample code:
LoadOptions loadOptions = new LoadOptions(LoadFormat.AUTO);
FileFormatInfo finfo = FileFormatUtil.detectFileFormat("f:\\files\\character_spacing_prblm.xls");
if (finfo.getFileFormatType() == FileFormatType.UNKNOWN)
{
loadOptions = new TxtLoadOptions(LoadFormat.TAB_DELIMITED);
}
loadOptions.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Workbook w = new Workbook("f:\\files\\character_spacing_prblm.xls",loadOptions);
System.out.println(w.getWorksheets().get(0).getCells().get("A1").getStringValue());//V e n d o r N u m b e r
I have logged a ticket with an id “CELLSJAVA-43503” for your issue. We will look into it soon.
Once we have an update on it, we will let you know.
We evaluated your issue further and found it is not an issue with the APIs. Please try to set the encoding before loading the template file. See the following sample code that works fine as we tested:
e.g. Sample code:
TxtLoadOptions loadOptionsTxt = new TxtLoadOptions(LoadFormat.TAB_DELIMITED);
loadOptionsTxt.setEncoding(Encoding.getUnicode());
LoadOptions loadOptions = new LoadOptions(LoadFormat.AUTO);
FileFormatInfo finfo = FileFormatUtil.detectFileFormat("f:\\files\\character_spacing_prblm.xls");
if (finfo.getFileFormatType() == FileFormatType.UNKNOWN)
{
loadOptions = new TxtLoadOptions(LoadFormat.TAB_DELIMITED);
loadOptions = loadOptionsTxt;
}
loadOptions.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Workbook w = new Workbook("f:\\files\\character_spacing_prblm.xls",loadOptions);
System.out.println(w.getWorksheets().get(0).getCells().get("A1").getStringValue());
Well, I am afraid, it is not possible to auto detect the encoding type of a text format like CSV or tab delimited, therefore you have to explicitly set the encoding using the TxtLoadOptions class.