using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NPOI.SS.Util;
using NPOI.SS.UserModel;
using System.Data;
using System.Collections;
using System.IO;
using NPOI.HSSF.UserModel;
using NPOI.HSSF.Util;
using Model;
using WebSite.Tools.Report;
namespace AxxicsWeb.Tools.Report
{
public class MaterialInReport : CreateExcel
{
/// <summary>
/// 锁定方法
/// </summary>
public static readonly Object lockobj = new Object();
// 单元格格式:默认左对齐
private ICellStyle style0 = null;
// 单元格格式:居中
private ICellStyle style1 = null;
// 单元格格式:居中 格式(.00)
private ICellStyle style2 = null;
// 报表模板文件名
public static string modeName = "report.xls";
// 工作簿
private HSSFWorkbook hssfworkbook = null;
// 工作表
private ISheet sheet = null;
public byte[] GetExcel(Hashtable ht)
{
// 所有的slipInfo数据
IList<SlipInfo> slist = ht["items"] as IList<SlipInfo>;
// 查询参数:SlipInfo
SlipInfo param = ht["s"] as SlipInfo;
// 传票类型
string slipType = param.SlipType;
// 表头数据 数组
string[] headers = null;
// 存表头的list
List<List<Hashtable>> data = new List<List<Hashtable>>();
// 材料入、出库
if (slipType == "01" || slipType == "02")
headers = new string[] { "No.", "供应商编号", "供应商名称", "产品编号", "产品名称", "数量", "单位", "入库时间" };
// 产品入、出库
else if (slipType == "03" || slipType == "04")
headers = new string[] { "No.", "客户编号", "客户名称", "产品编号", "产品名称", "数量", "单位", "入库时间" };
// 材料转成品出库
else if (slipType == "05")
headers = new string[] { "No.", "客户编号", "客户名称", "供应商编号", "供应商名称", "产品编号", "产品名称", "数量", "单位", "入库时间" };
//创建工作簿和工作表
this.CreateHSworkbook();
// 创建表头
IRow row = sheet.CreateRow(2);
// 列的数量: headers.Count()
for (int i = 0, max = headers.Count(); i < max; i++)
c#导出报表
最新推荐文章于 2020-11-11 10:08:03 发布