AnAng

Nuget包名为

epplus.core

 

命名空间OfficeOpenXml

 

  string localFileName = path + Path.DirectorySeparatorChar + fileName;
                FileInfo file = new FileInfo(localFileName);
                using (ExcelPackage package = new ExcelPackage(file))
                {
                    ExcelWorkbook wb = package.Workbook;

                    //配置文件属性  
                    wb.Properties.Title = "库存导入模板";
                    // 添加worksheet
                    ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("商品库存");
                    //添加头
                    worksheet.Cells[1, 1].Value = "商品ID";
                    worksheet.Cells[1, 2].Value = "商品名称";
                    worksheet.Cells[1, 3].Value = "货号";
                    worksheet.Cells[1, 4].Value = "原价";
                    worksheet.Cells[1, 5].Value = "售价";
                    worksheet.Cells[1, 6].Value = "数量";
                    worksheet.Cells[1, 7].Value = "库存规格1";
                    worksheet.Cells[1, 8].Value = "库存规格2";

                    //获取当前商户库存数据模板
                    var items = _pser.GetImportInnentoryList(CurrentVendorID);
                    int rowindex = 1;
                    foreach (var item in items)
                    {
                        rowindex++;
                        //添加值
                        worksheet.Cells[rowindex, 1].Value = item.ProductID;
                        worksheet.Cells[rowindex, 2].Value = item.ProductName;
                        worksheet.Cells[rowindex, 3].Value = item.ArtNo;
                        worksheet.Cells[rowindex, 4].Value = item.TagPrice;
                        worksheet.Cells[rowindex, 5].Value = item.Price;
                        worksheet.Cells[rowindex, 6].Value = item.Quantity;
                        worksheet.Cells[rowindex, 7].Value = item.Specification1;
                        worksheet.Cells[rowindex, 8].Value = item.Specification2;

                    }
                    package.Save();
                }

跑是肯定跑不通的,因为我是COPY的

分类:

技术点:

相关文章:

  • 2022-02-14
  • 2021-12-29
  • 2022-12-23
  • 2021-11-07
  • 2021-12-22
  • 2022-02-18
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2022-02-16
  • 2022-03-02
  • 2022-12-23
  • 2022-01-11
  • 2021-06-25
相关资源
相似解决方案