EPPLus語法應用

2021-09-24 22:56:05 字數 1977 閱讀 3983

using(excelpackage package = new excelpackage(new fileinfo(@"d:\sample.xlsx")))

以下語句必須在using語句中編寫

excelworksheet sheet = package.workbook.worksheets.add("sheetname");
sheet.cells[1, 1].value = "id";

sheet.cells[1, 2].value = "product";

sheet.cells["a4"].value = "price";

//將從[a,b]到[a,b]中間的單元格合併。

sheet.cells[int a,int b,int a,int b].merge = true;

var cell = sheet.cells[1,1];
//字型名

sheet.cells[2, 1, 2, 10].style.font.name = "宋體";

//字型粗體

sheet.cells[2, 1, 2, 10].style.font.bold = true;

//字型大小

sheet.cells[1, 1].style.font.size = 1;

//水平對齊

sheet.cells[1,1,a,b].style.horizontalalignment = excelhorizontalalignment.center;

//垂直對齊

worksheet.cells.style.verticalalignment = excelverticalalignment.bottom;

worksheet.cells.style.fill.patterntype= excelfillstyle.solid; 

worksheet.cells.style.fill.backgroundcolor.setcolor(color.lightblue);

sheet.cells[a,b].style.wraptext= true;
sheet.cells[a,b,a,b].style.numberformat.format= "0.00";
sheet.cells[1, 1].style.font.color.setcolor(color.red);
//設定邊框,及其顏色

sheet.cells[1, 1].style.border.borderaround(excelborderstyle.thin, color.fromargb(191, 191, 191));

//設定列寬

sheet.column(1).width = 15;

//wpf 以與裝置無關的單位(每個單位 1/96 英吋)。

sheet.column(1).width=column.actualwidth;

//設定行高

sheet.row(b).height = 12;

//單元格自適應寬高

EPPlus設定Excel公式

excel中提供了功能強大的公式,epplus同樣也支援excel格式。rowcount columncount 整數,分別是行計數器 列計數器 thiscell worksheet.cells rowcount,columncount string startcell worksheet.cell...

EPPlus設定Excel條件格式

在excel中,可以設定條件格式,例如當單元格中的值小於0時,突出顯示,如圖 epplus也可以實現條件模式 epplus提供了條件格式的方法 conditionalformatting 該物件中含有預定義的規則,同時也支援自定義規則。以下 則是利用預定義的規則去實現 worksheet.dimen...

oracle SAMPLE 語法應用

sample抽樣函式用於支援資料探勘。sample 函式使得資料分析操作在樣本資料上進行,而不是在整張表上進行。選擇10 的記錄 select from atest sample 11 選擇0.1 的記錄 select from atest sample 0.1 根據資料塊選擇1 的記錄 selec...