讀取.xlsx常見方式有:
讀取.xls常見的方式有:1. workbook wb = new xssfworkbook(new fileinputstream(filename));
2. workbook wb = workbookfactory.create( new file(filename));
1. workbook wb = new hssfworkbook(new fileinputstream(filename));
2. workbook wb = workbookfactory.create( new file(filename));
hssfworkbook wb = new hssfworkbook();
hssfsheet sheet = wb.createsheet(sheetname);
hssfrow row = sheet.createrow(0);
hssfcell cell = row.createcell(0);
cell.setcellvalue(""); //設定單元格內容
cell.setcellstyle(cellstyle); //設定單元格風格
//將上面建立的workbook寫出到excel檔案,字尾為.xls
fileoutputstream output = null;
try catch (exception e) finally catch (ioexception e)
}
//設定單元格樣式
hssfcellstyle cellstyle = wb.createcellstyle();
cellstyle.setborderbottom(hssfcellstyle.border_thin); //下邊框
cellstyle.setborderleft(hssfcellstyle.border_thin);//左邊框
cellstyle.setbordertop(hssfcellstyle.border_thin);//上邊框
cellstyle.setborderright(hssfcellstyle.border_thin);//右邊框
cellstyle.setalignment(hssfcellstyle.align_center); // 水平居中
cellstyle.setverticalalignment(hssfcellstyle.vertical_center); //垂直居中
cellstyle.setwraptext(true);//自動換行
cellstyle2.setfillforegroundcolor(hssfcolor.red.index); //設定背景顏色
cellstyle2.setfillpattern(hssfcellstyle.solid_foreground);//設定填充格式
// 表示從【first row,firstcol】 到【lastrow,lastcol】 將這塊區域合併為乙個單元
// 需要注意 如果合併單元格也要有樣式,可以對區域內每個單元格都設定樣式,這樣合併之後就不會覆蓋掉樣式
sheet.addmergedregion(new cellrangeaddress(firstrow, lastrow, firstcol, lastcol));
public static void showexcel() throws exception
system.out.println("---sheet表"+i+"處理完畢---");}}
}
新建立生成的表,如果有建立空行,即執行了row = sheet.createrow但是沒有往裡面新增內容,報錯以後,如果沒有進行改動(人工開啟生成的**進行修改),那程式再次讀取時 row!=null 但是 cell == null,因為並沒有建立cell!如果有改動,再次讀取時row==null !// 呼叫這個新增方法,一次呼叫新增一條
private static void insert(string info)
row r = sheet.createrow(count++);
for(int i=0;i<17;i++)
}
dataframe常用功能整理
去除某幾列重複的行資料。a b 相同,則刪除重複行,保留第乙個。keep引數可以為first last和false 不保留 df.drop duplicates subset a b keep first inplace true 去除完全重複的行資料。保留第乙個 df.drop duplicate...
SAP常用功能
1 sap外觀 幫助圖示右側的按鈕是customizing of local layout 定製本地布局 按鈕,可以用它來變更sap gui顯示介面的風格。2 sap導航 1 在sap print list視窗裡,如果不想在保持期內儲存系統假離線請求,在print screen list 列印頁面列...
IOS 常用功能
對xib檔案的處理 xib的載入可以通過 nsbundle maibundle loadnibnamed nsstring str owner nsstring temp dic nsdictionary dic 載入 xib的fileowner檔案。然後通過下標得到sub 如果要獲取xib中固定的...