2014-10-29 127 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的簡單輸出線圖。

相關問題