poi匯入記錄一下 簡單操作

2021-10-04 17:33:32 字數 2521 閱讀 7583

最基本的poi匯入老記不住 , 所以簡單記錄一下方便後期來看…

poi匯入匯出依賴 :

multipartfile file = multrequest.getfile("file"); //務必與前端input的mame一致

string filename = file.getoriginalfilename(); //獲取上傳的xls的name

workbook workbook=null;

inputstream in = file.getinputstream();

if(filename.endswith("xls") || filename.endswith("xls"))else

in.close();

try

}} catch (exception e)

匯入工具類:

public class myexcelutils 

sheet sheet = null;

row row = null;

cell cell = null;

list = new arraylist>();

//遍歷excel中所有的sheet

for (int i = 0; i < work.getnumberofsheets(); i++)

//遍歷當前sheet中的所有行

for (int j = sheet.getfirstrownum(); j <= sheet.getlastrownum(); j++)

//遍歷所有的列

listli = new arraylist();

for (int y = row.getfirstcellnum(); y < row.getlastcellnum(); y++)

list.add(li);}}

in.close();

return list;

}/**

* * 描述:根據檔案字尾,自適應上傳檔案的版本

* * @param instr,filename

* * @return

* * @throws exception

*

*/public workbook getworkbook(inputstream instr, string filename) throws exception else if (excel2007u.equals(filetype)) else

return wb;

}/**

* * 描述:對**中數值進行格式化

* * @param cell

* * @return

*

*/public object getcellvalue(cell cell) else if ("m/d/yy".equals(cell.getcellstyle().getdataformatstring())) else

break;

case cell.cell_type_boolean:

value = cell.getbooleancellvalue();

break;

case cell.cell_type_blank:

value = "";

break;

default:

break;

}return value;}}

工具類呼叫方式 :

//該處可呼叫service相應方法進行資料儲存到資料庫中,現只對資料輸出

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

return jsonobject.parseobject(result);

}

簡單寫一下模組的匯入

根據我所學到的知識,python 當中先是def 定義乙個函式 如果這個檔案當中定義的函式多了 之後 別的檔案要用到 a檔案當中的函式 就可以匯入 a檔案 然後 a.函式名字 就可以呼叫這個函式了。省時省力 比如說 re time os sys 等等模組就是這樣使用的。可以把函式當中工具來看,而模組...

整理一下當年的學習筆記之 poi匯入匯出

或許只有我知道我寫的是什麼 匯出的例子 public void daochu throws exception service層 public class ypxximportserviceimpl implements hxlsoptrowsinte ce 新增唯一校驗 校驗通用名 劑型 規格 轉...

git常用的操作記錄一下

進入需要建立 庫的資料夾 cd 檔案路徑 建立初始化倉庫 git init 拉取遠端倉庫到本地 git clone 倉庫路徑 新增檔案到暫存區 提交到本地倉庫 檢視工作區狀態 git status 對比工作區變化 git diff 建議將beyond compare配置為diff工具,用於diff以...