小编use*_*961的帖子

使用apache poi写入xlsm(Excel 2007)

我编写了用于编写xlsm的java文件(Excel 2007).

使用Apache POI库,编写xlsx文件是成功的.编写xlsm文件是成功的.但是由于打开xlsm文件时出错,我无法打开xlsm文件.

使用Apache POI Library编写xlsm文件是否可行?

如果编写xlsm是可行的,请提供指导如何使用Apache poi库编写xlsm文件.

XSSFWorkbook workBook = new XSSFWorkbook();
XSSFSheet sheet = workBook.createSheet("Related_SRC");
String realName = "Test.xlsm";
File file = new File("C:\\sdpApp", realName);
try {
    FileOutputStream fileOutput = new FileOutputStream(file);
        workBook.write(fileOutput);
        fileOutput.close();
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

谢谢

java excel apache-poi xlsm

8
推荐指数
1
解决办法
2万
查看次数

分裂的正则表达式模式

我想解决这个问题.

  • , 逗号:拆分条款
  • " 双引号:字符串值(忽略特殊字符)
  • [] 排列

例如:

输入: a=1,b="1,2,3",c=[d=1,e="1,2,3"]

预期产量:

    a=1
    b="1,2,3"
    c=[d=1,e="1,2,3"]
Run Code Online (Sandbox Code Playgroud)

但我无法超越结果.

我写了下面的代码:

 String line = "a=1,b=\"1,2,3\",c=[d=1,e=\"1,11\"]";
 String[] tokens = line.split(",(?=(([^\"]*\"){2})*[^\"]*$)");
 for (String t : tokens)
      System.out.println("> " + t);
Run Code Online (Sandbox Code Playgroud)

我的输出是:

a=1
b="1,2,3"
c=[d=1
e="1,11"]
Run Code Online (Sandbox Code Playgroud)

我需要更改什么才能获得预期的输出?我应该坚持正则表达式还是其他解决方案更灵活,更容易维护?

java regex parsing

-6
推荐指数
1
解决办法
733
查看次数

标签 统计

java ×2

apache-poi ×1

excel ×1

parsing ×1

regex ×1

xlsm ×1