本文整理匯總了C#中OfficeOpenXml.ExcelWorksheet.InsertRow方法的典型用法代碼示例。如果您正苦於以下問題:C# ExcelWorksheet.InsertRow方法的具體用法?C# ExcelWorksheet.InsertRow怎麽用?C# ExcelWorksheet.InsertRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OfficeOpenXml.ExcelWorksheet
的用法示例。
在下文中一共展示了ExcelWorksheet.InsertRow方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FillExcelData
public override void FillExcelData(ExcelWorksheet sheet)
{
FillData();
if (Data == null || Data.Count == 0)
return;
int startRow = DataRowIndex;
int rowIndex = startRow;
ExcelRange cell = null;
RmsAuto.Store.Acctg.ClientProfile profile = SiteContext.Current.CurrentClient.Profile;
SellerInfo seller = GetSellerInfo();
sheet.InsertRow(rowIndex, Data.Count(), rowIndex);
int i = 1;
foreach (var item in Data)
{
cell = sheet.Cells[rowIndex, 1];
cell.Value = i;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
var border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 2];
cell.Value = item.Manufacturer;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 3];
cell.Value = item.OrderNumber;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 4];
cell.Value = item.PartNumber;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 5];
cell.Value = item.PartName;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 6];
cell.Value = item.Qty;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 7];
cell.Value = item.Price;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
cell = sheet.Cells[rowIndex, 8];
cell.Value = item.Price * item.Qty;
cell.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
border = cell.Style.Border;
border.Left.Style = border.Right.Style = border.Bottom.Style = border.Top.Style = ExcelBorderStyle.Thin;
i++;
rowIndex++;
}
cell = sheet.Cells[rowIndex + 1, 8];
cell.Value = Data.Sum(x => x.Total);
cell = sheet.Cells[1, 1];
cell.Value = String.Format(ConfigurationManager.AppSettings["ExcelTemplate.InvoiceTitle"], profile.AcctgId + "/" + DateTime.Now.ToString("hhmmss"), DateTime.Now.ToShortDateString());
cell = sheet.Cells[rowIndex + 3, 1];
cell.Value = String.Format(ConfigurationManager.AppSettings["ExcelTemplate.InvoiceTotal"], Data.Sum(x => x.Qty), Data.Sum(x => x.Total));
cell = sheet.Cells[4, 1];
cell.Value = cell.Value.ToString() + seller.CompanyName + ", " + seller.Address + ", " + seller.Phone;
cell = sheet.Cells[5, 1];
cell.Value = cell.Value.ToString() + profile.ClientName + ", " + profile.ShippingAddress;
}
示例2: InsertWeek
private void InsertWeek(ref ExcelWorksheet ws, WeekForExcel week)
{
var nameTable = ws.Names[string.Format("Tabla{0}", week.WeekNumber)];
ws.InsertRow(nameTable.Start.Row, week.WeekTable.Rows.Count);
var nameTableNew = ws.Cells[nameTable.Address].LoadFromDataTable(week.WeekTable, false);
ws.Cells[nameTableNew.Address].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
ws.Cells[nameTableNew.Address].Style.Fill.BackgroundColor.SetColor(System.Drawing.ColorTranslator.FromHtml("#FFFF99"));
//estilo para el footer
ExcelRange rangeFooter = ws.Cells[nameTableNew.End.Row, 1, nameTableNew.End.Row, nameTableNew.End.Column];
rangeFooter.Style.Numberformat.Format = (this.IsPesosMoney) ? _format_pesos : _format_dollars;
rangeFooter.Style.Font.Bold = true;
foreach (var cell in rangeFooter)
if (cell.Value != null && cell.Value.ToString() != "Total Día:")
cell.Value = decimal.Parse(cell.Value.ToString());
this.SetBorders(ws.Cells[nameTableNew.Address]);
this.PaintWeek(ref ws, nameTableNew.Address);
}