讀取EXCEL ,EXCEL值轉化,單元格樣式

2022-06-15 16:54:10 字數 3256 閱讀 4673

//讀取excel

public static workbook readexcel(string filepath)

string extstring = filepath.substring(filepath.lastindexof("."));

inputstream is = null;

try else if(".xlsx".equals(extstring))else

} catch (filenotfoundexception e) catch (ioexception e)

return wb;

}

//excel值轉化

public static object getcellformatvalue(cell cell)else

break;

}case cell.cell_type_formula:else

break;

}case cell.cell_type_string:

default:

cellvalue = "";

}}else

return cellvalue;

}

/**

* @功能描述 設定excel文件(多表單)

* @param tname

* excel表名集

* @param theader

* excel表頭資料集

* @param tvalue

* excel表單資料集(除表頭)

* @param theaderstyle

* excel表頭單元格樣式

* @param tvaluestyle

* excel表單資料單元格樣式(除表頭)

* @param filepath

* excel檔案位址

* @throws exception

* 異常往上丟擲

*/public void exportexcel(arraylisttname,

arraylist> theader,

arraylist>> tvalue,

arraylist> theaderstyle,

arraylist> tvaluestyle, outputstream fileoutput)

// 匯出excel檔案

this.export(workbook, fileoutput);

} catch (exception e) ",e );

} }

/**

* @功能描述 設定excel表單

* @param tname

* excel表名

* @param theader

* excel表頭資料集

* @param tvalue

* excel表單資料集(除表頭)

* @param theaderstyle

* excel表頭單元格樣式

* @param tvaluestyle

* excel表單資料單元格樣式(除表頭)

* @throws exception

* 異常往上丟擲

*/private void setsheet(string tname, arraylisttheader,

arraylist> tvalue,

maptheaderstyle, maptvaluestyle)

throws exception

trow = sheet.createrow(sheet.getlastrownum() + 5);

hssfcellstyle cellstyle = workbook.createcellstyle();

hssffont font = workbook.createfont();

font.setcolor(hssfcolor.red.index);

cellstyle.setfont(font);

hssfcell cell = trow.createcell(0);

cell.setcellstyle(cellstyle);

cell.setcellvalue("注:方案基本資訊無要求或無限制為-1");

} catch (exception e) ",e );

} }

/**

* @功能描述 設定excel表單行資料

*/@suppresswarnings("unchecked")

private hssfrow settrow(hssfrow row, arraylist trow,

maptheaderstyle) throws exception

if (obj instanceof string)

if (obj instanceof boolean)

if (obj instanceof date)

if (obj instanceof calendar)

if (obj instanceof double)

}} catch (exception e) ",e );

} return row; // 返回

}

/**

* @功能描述 設定單元格樣式

*/private hssfcellstyle setcellstyle(mapfontstyle)

throws exception catch (exception e) ",e );

} return cellstyle; // 返回

}

/**

* @功能描述 匯出excel

*/private void export(hssfworkbook workbook, outputstream fileoutput)

throws exception catch (filenotfoundexception e) ",e );

} catch (exception e) ",e );

} finally catch (ioexception e) ",e );

}} }

opencv 讀取畫素值

話不多說,新手在不斷學習,剛剛看見讀取每個畫素點值很是好奇。include include using namespace std int main 不過通過上訴方法在速度方面會比較慢。可以通過如下方法加快訪問,更改速度。iplimage成員有 int nsize int id 比較重要的兩個元素是...

std move 強制轉化為右值

在c 11中,標準庫在中提供了乙個有用的函式std move,這個函式的名字具有迷惑性。實際上std move並不能移動任何東西,它唯一的功能是將乙個左值強制轉化為右值引用,繼而我們可以通過右值引用使用該值,以用於移動語義。從實現上講,std move基本等同於乙個型別轉換 static cast ...

讀取角色的血值

分析出值基址 偏移 95e800 1c 24 918 14 1c 角色物件基址 3c 當前座標 x,h,y 7c 當前座標 x,h,y 25c 當前血值 260 當前魔力值 274 血值上限 278 魔力值上限 28c 防禦 gamecaption element client 遊戲視窗類名 qel...