Chinese characters in embedded fileName

Hello,

When I embed a file with a chinese name (ex : ‘申請進入.txt’) in an excel xlsx file, and then try to open the embedded file in excel, the name set by calling ‘setObjectSourceFullName(“申請進入.txt”)’ is not well-displayed in notepad.
If I open directly the file ‘申請進入.txt’ in notepad, the name is well-displayed.

envt : java 1.8 / aspose-cells-19.9.jar

Best regards

@joelle.auffret,

Thanks for providing us details.

Please try using our latest version/fix: Aspose.Cells for Java v18.1.x

If you still find the issue, kindly do share the sample code (runnable) to reproduce the issue on our end, we will check it soon. Also attach your template file(s).

Hello, I have tried with aspose-cells-18.1.jar and the problem remains. In attachment the example used.for_support.zip (11.7 KB)

@joelle.auffret,

Thanks for providing us sample code and template file.

After an initial test, I observed the issue as you mentioned by using your sample code with your template file. I found that when adding a text file (containing Chinese chars in its name) as an embedded object and then clicking on the Ole Object in the output file, the file name (title) is not well-displayed in notepad.
e.g
Sample code:

import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.IOException; 
import java.lang.reflect.InvocationTargetException; 
import java.nio.file.Files; 
import java.nio.file.Path; 
import java.nio.file.Paths; 
import java.util.ArrayList; 
import java.util.Enumeration; 
import java.util.Hashtable; 
import java.util.List; 

import com.aspose.cells.OleObject; 
import com.aspose.cells.Workbook; 
import com.aspose.cells.Worksheet; 

// A SINGLE TEST 
// 



public class Aspose1Test 
{ 
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException 
    { 
String testFileTemplate = "F:\\Files\\chinese characters in\\ONE_TEMPLATE.xlsx"; 
Workbook wbTest = null; 
try { 
FileInputStream fisTemplateTest = new FileInputStream(new File(testFileTemplate)); 
wbTest = new Workbook(fisTemplateTest); 
} catch (FileNotFoundException e1) { 
// TODO Auto-generated catch block 
e1.printStackTrace(); 
} catch (Exception e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 


String testFileEmbedded = "F:\\Files\\chinese characters in\\申請進入.txt"; 
int indexSheetTest = 0; 
int rowCellTest = 5; 
int columnCellTest = 3; 
File fileToEmbedTest = new File(testFileEmbedded); 
byte[] dataTest = new byte[(int)fileToEmbedTest.length()]; 
String extensionTest = "txt"; 
byte[] imgTest = generatePreviewImage(extensionTest); 

try { 
FileInputStream fisToEmbedTest = new FileInputStream(fileToEmbedTest); 
fisToEmbedTest.read(dataTest); 
Worksheet sheetTest = wbTest.getWorksheets().get(indexSheetTest); 
// Add img 
int oleObjIndexTest = sheetTest.getOleObjects().add(rowCellTest, columnCellTest, 50, 50, imgTest); 
OleObject oleObjTest = sheetTest.getOleObjects().get(oleObjIndexTest); 

//Set embedded ole object data. 
oleObjTest.setDisplayAsIcon(true); 
oleObjTest.setObjectSourceFullName("申請進入.txt"); 
oleObjTest.setName("F:\\Files\\chinese characters in\\申請進入.txt"); 
oleObjTest.setObjectData(dataTest); 

fisToEmbedTest.close(); 
wbTest.save("F:\\Files\\chinese characters in\\ONE_RESULT1.xlsx"); 

} catch (IOException e) { 
System.out.println("writeFileInXls << Error while reading embedded file : "+ e); 
} catch (Exception e2) { 
System.out.println("writeFileInXls << Error while setObjectSourceFullName embedded file : "+ e2); 
} 
System.out.println("C'est FINI !!"); 

} 
     
private static byte[] generatePreviewImage(String extension) { 
Path path = null; 
String fileName = "F:\\Files\\chinese characters in\\TextFile.jpg"; 
path = Paths.get(fileName); 

byte[] data = null; 
try { 
data = Files.readAllBytes(path); 
} catch (IOException e) { 
System.out.println("generatePreviewImage >> file " + fileName + " not found in the filesystem!!!"); 
} 

return data; 
} 

} 

I have logged a ticket with an id “CELLSJAVA-42521” for your issue. We will look into it soon.

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

@joelle.auffret,

This is to inform you that we have fixed your issue CELLSJAVA-42521 now. We will soon provide the fix after performing QA and including other enhancements and fixes

@joelle.auffret

Thanks for using Aspose.Cells.

Please download and try the following fix and let us know your feedback.

it’s good for me now for the case I gave you as an example (java application). But I still have a problem in an EJB environment (the embedded file with the Chinese name can not be opened). Unfortunately I could not isolate the problem for this specific case.image.png (12.2 KB)

@joelle.auffret,

Thanks for the screenshot.

I am not sure if the issue (in your EJB environment) is related to Aspose.Cells APIs. Please make sure that you are using latest fix/version v18.2.4 on your EJB environment. Also, could you try your scenario/case using simple text file (having English chars in its name instead of Chinese chars) if it works fine or you still find the same issue as per your screenshot?

The issues you have found earlier (filed as CELLSJAVA-42521) have been fixed in this Aspose.Cells for Java 18.3 update. Please also check the <a href="Installation|Documentation

The issues you have found earlier (filed as CELLSJAVA-42521) have been fixed in this Aspose.Cells for Java 18.3 update. Please also check the document for your reference: Installation|Documentation