用jxl來生成Excel

2021-07-22 08:23:16 字數 1079 閱讀 2549

file file = new file("xx/xx/***.xls");

if (!file.getparentfile().exists())

workbook wb = null; //用來獲取工作簿

writableworkbook wwb = null; //建立工作簿

writablesheet sheet0 = null; //sheet

if (!file.exists()) else

// 表頭

string title = new string ;

for (int i = 0; i < title.length; i++)

// 獲取sheet的行數

int rows = sheet.getrows();

// 建立乙個數字型的單元格

numberformat nf = new numberformat("#0");

writablecellformat wcf = new writablecellformat(nf);

jxl.write.number number = new jxl.write.number(2, rows, total, wcf);

sheet.addcell(number);

// 獲取rows行的下標為1的單元格

cell c = sheet.getcell(1, rows);

writablecellformat format = new writablecellformat(c.getcellformat());

// 背景色紅色

format.setbackground(colour.red);

writablecell wc = (writablecell) c;

wc.setcellformat(format);

// 合併單元格

// rows行的下標3到11的合併

sheet.mergecells(3, rows, 11, rows);

// 寫單元格

wwb.write();

wwb.close();

JXL生成excel實戰

需求 完成乙個簡單excel的生成和匯出 前台 var flightstart flightdate1 val var flightend flightdate2 val var segment segment val var flightno flightno val var isauto isa...

利用jxl生成excel檔案

工程進行的差不多了,這兩天正在做excel相關的工作。鬱悶壞了,不知道為什麼eclipse老是提示輸出的方法已經被呼叫,明明只寫excel標題的時候可以生成的,在csdn上搜了半天,終於找到原因。下面是一位老兄的例子 匯出某個object陣列的內容到excel public static boole...

通過JXL生成Excel報表!

最近做專案中,中間有乙個功能是用 jxl外掛程式生成 excel 報表,因為之前沒有弄過這些,所以都是從網上找一些資料 文件現學。現在功能已經做完了,就整理了一下,留著自己以後看,以免忘記 廢話不多話,直接上 建立乙個 excel 檔案 string path d report.xls fileou...