本文整理汇总了C#中Workbook.getBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.getBytes方法的具体用法?C# Workbook.getBytes怎么用?C# Workbook.getBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workbook
的用法示例。
在下文中一共展示了Workbook.getBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportOperateLogWithExcel
public ActionResult ExportOperateLogWithExcel()
{
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("Sheet1");
var list = db.T_ZC_MemberLog.ToList();
foreach (var log in list)
{
ExcelGenerator.SpreadSheet.Row row = new ExcelGenerator.SpreadSheet.Row();
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.ID.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.StartDateTime.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.EndDateTime.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Message.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(Enum.GetName(typeof(OperateTypes),log.OperateType)));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(Enum.GetName(typeof(GenerateSystem),log.GenerateModule)));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.MemberID.ToString()));
worksheet.Rows.Add(row);
}
workbook.Worksheets.Add(worksheet);
return new ExcelResult(workbook.getBytes(), "Export.xls");
}
示例2: ExportErrorLogWithExcel
public ActionResult ExportErrorLogWithExcel()
{
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("错误日志");
var list = db.T_ZC_CommonLog.Where(l => l.Level == "Error").ToList();
foreach( var log in list)
{
ExcelGenerator.SpreadSheet.Row row = new ExcelGenerator.SpreadSheet.Row();
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.ID.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Level.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Logger.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Message.ToString()));
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Source.ToString()));
if(log.Exception.Length <= 500)
{
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Exception.ToString()));
}
else
{
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.Exception.Substring(0, 500)));
}
row.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(log.User.ToString()));
worksheet.Rows.Add(row);
}
workbook.Worksheets.Add(worksheet);
return new ExcelResult(workbook.getBytes(), "Export.xls");
}
示例3: GetXLS
//returns an XLS Stream
public static byte[] GetXLS(IList<IList<string>> table)
{
//Create a workbook
Workbook workbook = new Workbook();
//Create a worksheet
Worksheet worksheet = new Worksheet("Report");
//Create a new row
foreach (var row in table)
{
var xlsRow = new ExcelGenerator.SpreadSheet.Row();
foreach (var col in row)
{
xlsRow.Cells.Add(new ExcelGenerator.SpreadSheet.Cell(col));
}
worksheet.Rows.Add(xlsRow);
}
//Add worksheet to Workbook
workbook.Worksheets.Add(worksheet);
return workbook.getBytes();
}