We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

条件格式的颜色打标错误

春节快乐!
我在将excel文件转换为xml文件后,再将xml文件转换为excel文件后条件格式的字体颜色消失。
image.png (63.5 KB)
image.png (30.0 KB)
测试的excel文件如上图,转换为xml文件代码如下

 	public static void main(String[] args) throws Exception {
		String inPath = "C:\\test\\test.xlsx";
		String outPath = "C:\\test\\test.xlsx.xml";
		FileOutputStream fos = new FileOutputStream(outPath);
		Workbook wb = new Workbook(inPath);
		wb.save(fos, SaveFormat.HTML);
		fos.close();
		wb.dispose();
	}

但是,当我再将xml文件转换成excel文件后,条件格式的字体颜色消失。

public static void main(String[] args) throws Exception {
	String inPath = "C:\\test\\test.xlsx.xml";
	String outPath = "C:\\test\\test.xlsx.xml.xlsx";
	BufferedInputStream bis = new BufferedInputStream(new FileInputStream(inPath));
	FileOutputStream fos = new FileOutputStream(outPath);
	LoadOptions lo = new LoadOptions(LoadFormat.HTML);
	Workbook wb = new Workbook(bis, lo);
	wb.save(fos, SaveFormat.XLSX);
	bis.close();
	fos.close();
	wb.dispose();
}

image.png (25.7 KB)

@baicai,

能否请您压缩并附上您输入的 Excel 文件。 我们会尽快检查您的问题。

test.zip (14.4 KB)

@baicai,
As save format is set as Html with wb.save(fos, SaveFormat.HTML),the saved file is html,not SpreadsheedML(Excel 2003 xml data).
Html does not support conditional formatting, so conditional formatting is lost.
If you want to save the file as SpreadsheedML, please simply use wb.save(fos, SaveFormat.SPREADSHEET_ML)

谢谢,祝您生活愉快!!!!!