將資料庫記錄匯出到Excel模板

2021-10-10 07:16:53 字數 2268 閱讀 8021

public class wasteexcel );

}tabledatalist.add(sheet1);

getxlsx(sheet1,「pp」,「2019-10」,133);

}

public static string getxlsx(listtable1, string mdlpath, string filename, integer businessid) throws ioexception

}}

// sheet1.createrow(2);

}

//新增完畢複製格式

for (int j = 0; j < table1.size() - 24; j++)

// end correcting bug

}system.out.println("總行數:" + sheet1.getlastrownum());

//填入資料

int startindex=1;

int sumcloum = sheet1.getrow(0).getphysicalnumberofcells();

for (int i = 0; i < table1.size(); i++)

}

// long time = system.currenttimemillis();

file filed = new file(path+"/standingbook/"+currenttime);

if(!filed.exists())

try (fileoutputstream out = new fileoutputstream(path+"/standingbook/"+currenttime+"/"+filename+businessid+".xlsx");)

}

return path+"/standingbook/"+currenttime+"/"+filename+businessid+".xlsx";

}/**

* 行複製功能

* * @param wb 工作簿

* @param fromrow 從哪行開始

* @param torow 目標行

* @param copyvalueflag true則連同cell的內容一起複製

*/public static void copyrow(workbook wb, row fromrow, row torow, boolean copyvalueflag)

sheet worksheet = fromrow.getsheet();

for (int i = 0; i < worksheet.getnummergedregions(); i++)

}}/**

* 複製單元格

* @param srccell

* @param distcell

* @param copyvalueflag true則連同cell的內容一起複製

*/@suppresswarnings("deprecation")

public static void copycell(workbook wb, cell srccell, cell distcell, boolean copyvalueflag)

// 不同資料型別處理

celltype srccelltype = srccell.getcelltypeenum();

distcell.setcelltype(srccelltype);

if (copyvalueflag) else

} else if (srccelltype == celltype.string) else if (srccelltype == celltype.blank) else if (srccelltype == celltype.boolean) else if (srccelltype == celltype.error) else if (srccelltype == celltype.formula)

}}public static void drawimageonexcelsheet(xssfsheet sheet, int row, int col,

int left/*in px*/, int top/*in pt*/, int width/*in px*/, int height/*in pt*/, int pictureidx) throws exception

將資料匯出到excel

using system using system.data.oledb using system.io using system.windows.forms namespace postgraduateclient public sqltoexcel string tablename public...

將資料匯出到excel

前台jsp呼叫 function outexe action 將資料匯出到excel action value lpm grpinfoexl public string lpmexl throws exception else if g.getregtime null else rows 當stri...

將資料庫查詢的資訊匯出到Excel

生成excel及資料public class exportexcel else catch exception e finally trycatch ioexception e finally catch ioexception e 將資料寫入到excelpublic 生成excel和一種字型pri...