2014-10-29 88 views

回答

1

我使用Apache POI 3.10。到目前为止,Apache POI XSSF无法添加行标记!所以,我用excel vba来做到这一点。

我所做的是我创建了一个带有VBA宏的xlsm模板,以便在用户打开xlsm文件时添加行标记。此外,我们不能POI添加VBA宏为here提到,

Macros can not be created. The are currently no plans to support macros. However, 
reading and re-writing files containing macros will safely preserve the macros. 

因此,我们必须创建一个模板,并把它作为一个POI输入。

FileInputStream file = new FileInputStream(new File("template.xlsm")); 
XSSFWorkbook workbook = new XSSFWorkbook(file); 

这里是我的VBA宏:

Sub auto_open() 

Dim myChart As ChartObject 
    For Each myChart In Sheets("Sheet1").ChartObjects 
     For Each Series In myChart.Chart.SeriesCollection 
      Series.MarkerStyle = xlMarkerStyleSquare 
     Next 
    Next myChart 
End Sub 

通过使用此解决方案,我们可以添加更多的风格到POI的简单输出线图。

相关问题