根據模板生成帶公式的excel

2021-08-31 23:23:55 字數 2610 閱讀 9272

將模板(帶公式計算)放在專案路徑下某個資料夾

//1.生成工資表excel檔案

fileinputstream fileinputstream = null;

try catch (filenotfoundexception e)

xssfworkbook excel = null;

try catch (exception e)

xssfsheet sheet = excel.getsheetat(0);

//獲取模板中的標題

string title = sheet.getrow(0).getcell(0).getstringcellvalue();

//獲取模板中的列名

string rowvalue1 = new string[18];

string rowvalue2 = new string[3];

for (int i = 0; i< sheet.getrow(1).getphysicalnumberofcells() ; i++)

rowvalue1[i] = sheet.getrow(1).getcell(i).getstringcellvalue();

}rowvalue2[0] = sheet.getrow(2).getcell(12 ).getstringcellvalue();

rowvalue2[1] = sheet.getrow(2).getcell(13 ).getstringcellvalue();

rowvalue2[2] = sheet.getrow(2).getcell(14 ).getstringcellvalue();

file uploadfile = new file(uploadfilepath);

//判斷資料夾是否存在,如果不存在則建立資料夾

if (!uploadfile.exists())

fileoutputstream fos = null;

try

sheettemp.getrow(1).getcell(i).setcellvalue(rowvalue1[i]);

}sheettemp.getrow(2).getcell(12).setcellvalue(rowvalue2[0]);

sheettemp.getrow(2).getcell(13).setcellvalue(rowvalue2[1]);

sheettemp.getrow(2).getcell(14).setcellvalue(rowvalue2[2]);

//設定個人工資明細

sheettemp.getrow(3).getcell(0).setcellvalue(1);

sheettemp.getrow(3).getcell(1).setcellvalue(salaryschedule.getstaffname());

sheettemp.getrow(3).getcell(2).setcellvalue(salaryschedule.getfinanaccountunit());

sheettemp.getrow(3).getcell(3).setcellvalue(salaryschedule.getbasepay());

sheettemp.getrow(3).getcell(4).setcellvalue(salaryschedule.getpostwage());

sheettemp.getrow(3).getcell(5).setcellvalue(salaryschedule.getachievementbonus());

sheettemp.getrow(3).getcell(6).setcellvalue(salaryschedule.getmealsupplement());

sheettemp.getrow(3).getcell(7).setcellvalue(salaryschedule.getotherwelfarecosts());

sheettemp.getrow(3).getcell(8).setcellvalue(salaryschedule.getperformancedeductions());

sheettemp.getrow(3).getcell(9).setcellvalue(salaryschedule.getdeductionsattend());

sheettemp.getrow(3).getcell(11).setcellvalue(salaryschedule.gethousingstock());

sheettemp.getrow(3).getcell(12).setcellvalue(salaryschedule.getpension());

sheettemp.getrow(3).getcell(13).setcellvalue(salaryschedule.getmedicalcare());

sheettemp.getrow(3).getcell(14).setcellvalue(salaryschedule.getunemployment());

workbook.write(fos);

fos.flush();

fos.close();

} catch (filenotfoundexception e) catch (ioexception e)

根據Excel模板匯出Excel資料

給出 模板和資料 自動生成excel param type 預設為0 param path 模版路徑 param title 要顯示的標題 未用到 param exportname 匯出名稱 param tablehead 列表的表頭 未用到 param datalist 資料項 param dat...

根據模板生成word

var product list product list賦值 var filename 文件模板.docx var filernd upload temp session.sessionid.tostring parseint math.random 1000000 docx var fso ne...

C 根據Excel生成樹

需求 根據excel生成樹,excel的某些節點為屬性節點,如 列 樁號 構件編碼 測試屬性1 是列 分項工程名稱 的屬性,非節點。列 樁號 構件編碼 測試屬性1 以屬性的方式存在 匯入的思路 排除屬性列外,所有的列從左到右,樹的層級依次遞增,左邊列是右邊列的父節點 判斷乙個單元格是否已新增,獲取該...