我正在使用apache poi創建一個excel文檔。要在工作簿中創建新工作表,我寫下一個代碼:Apache POI。複製工作表
Workbook wb = new HSSFWorkbook();
Sheet sh = wb.createSheet();
此代碼創建並將工作表添加到工作簿。但我想先創建工作表,然後將其添加到工作簿。水木清華這樣的:
Sheet sh = new HSSFSheet();
wb.addSheet(sh);
我需要這樣的東西,因爲我想將數據從一個工作簿中的一個表複製到另一個工作簿中的另一個工作表(工作簿接口有方法Sheet cloneSheet(int)
)。但是工作簿界面沒有像addSheet(Sheet sh)這樣的方法。 另外HSSFWorkbook是final類,所以我不能擴展它來實現添加方法 我該怎麼做?