春节快乐!
我在将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)