Spire.XLS for Java 14.2.4 supports saving Kingdraw drawn OLE objects as images

2024-02-23 09:44:36

We are pleased to announce the release of Spire.XLS for Java 14.2.4. This version supports saving Kingdraw drawn OLE objects as images. What's more, some known issues are fixed successfully, such as the issue that the content was incorrect when converting Excel to PDF. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREXLS-5046 Supports saving Kingdraw drawn OLE objects as images.
	com.spire.xls.Workbook workbook = new com.spire.xls.Workbook();
	workbook.loadFromFile("data.xlsx");
	Worksheet sheet = workbook.getWorksheets().get(0);
	Object o =  sheet.getCellRange("C2").getFormulaValue();
	if (sheet.hasOleObjects()) {
		for (int i = 0; i < sheet.getOleObjects().size(); i++) {
			IOleObject oleObject = sheet.getOleObjects().get(i);
			OleObjectType oleObjectType = sheet.getOleObjects().get(i).getObjectType();
			byte[] picUrl = null;
			switch (oleObjectType) {
				case Emf:
					picUrl = oleObject.getOleData();;
					break;
			}
			if (picUrl != null) {
				byteArrayToFile(picUrl, "out.png");
				break;
			}
		}
	}
}

public static void byteArrayToFile(byte[] datas, String destPath) {
	File dest = new File(destPath);
	try (InputStream is = new ByteArrayInputStream(datas);
		 OutputStream os = new BufferedOutputStream(new FileOutputStream(dest, false));) {
		byte[] flush = new byte[1024];
		int len = -1;
		while ((len = is.read(flush)) != -1) {
			os.write(flush, 0, len);
		}
		os.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
Bug SPIREXLS-5072
SPIREXLS-5099
Fixes the issue that the content was incorrect when converting Excel to PDF.
Bug SPIREXLS-5076 Fixes the issue that the images were incorrect after copying content.
Bug SPIREXLS-5088 Fixes the issue that the program threw "A workbook must contain at least a visible worksheet" when converting XML to Excel.
Bug SPIREXLS-5089 Optimizes the setting of Locale in the setValue method.
Bug SPIREXLS-5095 Fixes the issue that the program threw "NullPointerException" when copying tables.
Bug SPIREXLS-5098 Fixes the issue that the text content styles changed when converting Excel to HTML.
Click the link below to download Spire.XLS for Java 14.2.4: