|
|
@ -4,7 +4,6 @@ using BBWY.Client.Models; |
|
|
|
using BBWY.Client.Models.FallWare; |
|
|
|
using BBWY.Client.Models.PackTask; |
|
|
|
using NPOI.XSSF.UserModel; |
|
|
|
using Spire.Xls; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Drawing; |
|
|
@ -625,92 +624,92 @@ namespace BBWY.Client.Helpers |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 打印封箱
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sealBoxModel"></param>
|
|
|
|
/// <param name="printName"></param>
|
|
|
|
/// <param name="boxCount"></param>
|
|
|
|
/// <param name="printCount"></param>
|
|
|
|
public static void PrintSealBoxData(SealBoxModel sealBoxModel, string printName, int boxCount, int printCount) |
|
|
|
{ |
|
|
|
// 100*180
|
|
|
|
///// <summary>
|
|
|
|
///// 打印封箱
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="sealBoxModel"></param>
|
|
|
|
///// <param name="printName"></param>
|
|
|
|
///// <param name="boxCount"></param>
|
|
|
|
///// <param name="printCount"></param>
|
|
|
|
//public static void PrintSealBoxData(SealBoxModel sealBoxModel, string printName, int boxCount, int printCount)
|
|
|
|
//{
|
|
|
|
// // 100*180
|
|
|
|
|
|
|
|
UnitConverHelper unitConverHelper = new UnitConverHelper(); |
|
|
|
// UnitConverHelper unitConverHelper = new UnitConverHelper();
|
|
|
|
|
|
|
|
var data = unitConverHelper.MmToPx(100, 180); |
|
|
|
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
|
|
|
string printNamePath = $"{applicationPath}/printSealName.init"; |
|
|
|
if (File.Exists(printNamePath)) |
|
|
|
{ |
|
|
|
File.Delete(printNamePath); |
|
|
|
} |
|
|
|
File.WriteAllText(printNamePath, printName); |
|
|
|
// var data = unitConverHelper.MmToPx(100, 180);
|
|
|
|
// var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
|
|
// string printNamePath = $"{applicationPath}/printSealName.init";
|
|
|
|
// if (File.Exists(printNamePath))
|
|
|
|
// {
|
|
|
|
// File.Delete(printNamePath);
|
|
|
|
// }
|
|
|
|
// File.WriteAllText(printNamePath, printName);
|
|
|
|
|
|
|
|
var excel = $"{applicationPath}/Resources/ExccelModel/sealbox.xlsx"; |
|
|
|
// var excel = $"{applicationPath}/Resources/ExccelModel/sealbox.xlsx";
|
|
|
|
|
|
|
|
var newExccel = $"{applicationPath}/Resources/ExccelModel/newsealbox.xlsx"; |
|
|
|
if (File.Exists(newExccel)) |
|
|
|
{ |
|
|
|
File.Delete(newExccel); |
|
|
|
} |
|
|
|
FileStream fs = new FileStream(excel, FileMode.Open, FileAccess.Read); |
|
|
|
XSSFWorkbook wb = new XSSFWorkbook(fs); |
|
|
|
var sheet = wb.GetSheetAt(0); // 得到第一个sheet
|
|
|
|
// var newExccel = $"{applicationPath}/Resources/ExccelModel/newsealbox.xlsx";
|
|
|
|
// if (File.Exists(newExccel))
|
|
|
|
// {
|
|
|
|
// File.Delete(newExccel);
|
|
|
|
// }
|
|
|
|
// FileStream fs = new FileStream(excel, FileMode.Open, FileAccess.Read);
|
|
|
|
// XSSFWorkbook wb = new XSSFWorkbook(fs);
|
|
|
|
// var sheet = wb.GetSheetAt(0); // 得到第一个sheet
|
|
|
|
|
|
|
|
var nameCell = sheet.GetRow(0).GetCell(0); // name列,第2行
|
|
|
|
var ageCell = sheet.GetRow(3).GetCell(0); // age列,第2行
|
|
|
|
// var nameCell = sheet.GetRow(0).GetCell(0); // name列,第2行
|
|
|
|
// var ageCell = sheet.GetRow(3).GetCell(0); // age列,第2行
|
|
|
|
|
|
|
|
|
|
|
|
XSSFWorkbook wb2 = new XSSFWorkbook(); |
|
|
|
sheet.CopyTo(wb2, "Sheet1", true, false); |
|
|
|
var sheet2 = wb2.GetSheet("Sheet1"); |
|
|
|
var nameCell2 = sheet2.GetRow(0).GetCell(1); |
|
|
|
nameCell2.SetCellValue(sealBoxModel.ShopName); |
|
|
|
// XSSFWorkbook wb2 = new XSSFWorkbook();
|
|
|
|
// sheet.CopyTo(wb2, "Sheet1", true, false);
|
|
|
|
// var sheet2 = wb2.GetSheet("Sheet1");
|
|
|
|
// var nameCell2 = sheet2.GetRow(0).GetCell(1);
|
|
|
|
// nameCell2.SetCellValue(sealBoxModel.ShopName);
|
|
|
|
|
|
|
|
sheet2.GetRow(3).GetCell(1).SetCellValue(sealBoxModel.WareName); |
|
|
|
// sheet2.GetRow(3).GetCell(1).SetCellValue(sealBoxModel.WareName);
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
int totalCount = 0; |
|
|
|
for (int i = 0; i < sealBoxModel.SealBoxSkus.Count; i++) |
|
|
|
{ |
|
|
|
var title = sealBoxModel.SealBoxSkus[i].SkuTitle; |
|
|
|
//if (title.Length>5)
|
|
|
|
//{
|
|
|
|
// title = title.Substring(0,5);
|
|
|
|
//}
|
|
|
|
totalCount += sealBoxModel.SealBoxSkus[i].WareHourseSkuCount; |
|
|
|
sheet2.GetRow(i + 6).GetCell(1).SetCellValue($"名称:{title}"); |
|
|
|
sheet2.GetRow(i + 6).GetCell(2).SetCellValue($"SKU:{sealBoxModel.SealBoxSkus[i].SkuId}"); |
|
|
|
sheet2.GetRow(i + 6).GetCell(3).SetCellValue($"数量:{sealBoxModel.SealBoxSkus[i].WareHourseSkuCount}"); |
|
|
|
// StringBuilder sb = new StringBuilder();
|
|
|
|
// int totalCount = 0;
|
|
|
|
// for (int i = 0; i < sealBoxModel.SealBoxSkus.Count; i++)
|
|
|
|
// {
|
|
|
|
// var title = sealBoxModel.SealBoxSkus[i].SkuTitle;
|
|
|
|
// //if (title.Length>5)
|
|
|
|
// //{
|
|
|
|
// // title = title.Substring(0,5);
|
|
|
|
// //}
|
|
|
|
// totalCount += sealBoxModel.SealBoxSkus[i].WareHourseSkuCount;
|
|
|
|
// sheet2.GetRow(i + 6).GetCell(1).SetCellValue($"名称:{title}");
|
|
|
|
// sheet2.GetRow(i + 6).GetCell(2).SetCellValue($"SKU:{sealBoxModel.SealBoxSkus[i].SkuId}");
|
|
|
|
// sheet2.GetRow(i + 6).GetCell(3).SetCellValue($"数量:{sealBoxModel.SealBoxSkus[i].WareHourseSkuCount}");
|
|
|
|
|
|
|
|
} |
|
|
|
sheet2.GetRow(25).GetCell(1).SetCellValue(totalCount); |
|
|
|
sheet2.GetRow(28).GetCell(1).SetCellValue(boxCount); |
|
|
|
FileStream fs1 = new FileStream(newExccel, FileMode.OpenOrCreate, FileAccess.ReadWrite); |
|
|
|
wb2.Write(fs1); |
|
|
|
fs1.Close(); |
|
|
|
fs1.Dispose(); |
|
|
|
Workbook workbook = new Workbook(); |
|
|
|
// }
|
|
|
|
// sheet2.GetRow(25).GetCell(1).SetCellValue(totalCount);
|
|
|
|
// sheet2.GetRow(28).GetCell(1).SetCellValue(boxCount);
|
|
|
|
// FileStream fs1 = new FileStream(newExccel, FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
|
|
|
// wb2.Write(fs1);
|
|
|
|
// fs1.Close();
|
|
|
|
// fs1.Dispose();
|
|
|
|
// Workbook workbook = new Workbook();
|
|
|
|
|
|
|
|
workbook.LoadFromFile(newExccel); |
|
|
|
// workbook.LoadFromFile(newExccel);
|
|
|
|
|
|
|
|
Worksheet wsheet = workbook.Worksheets[0]; |
|
|
|
// Worksheet wsheet = workbook.Worksheets[0];
|
|
|
|
|
|
|
|
wsheet.PageSetup.PaperSize = PaperSizeType.PaperA4; |
|
|
|
wsheet.PageSetup.Orientation = PageOrientationType.Portrait; |
|
|
|
wsheet.PageSetup.PrintArea = "A1:D31"; |
|
|
|
// wsheet.PageSetup.PaperSize = PaperSizeType.PaperA4;
|
|
|
|
// wsheet.PageSetup.Orientation = PageOrientationType.Portrait;
|
|
|
|
// wsheet.PageSetup.PrintArea = "A1:D31";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var print = workbook.PrintDocument; |
|
|
|
print.PrinterSettings.PrinterName = printName; |
|
|
|
print.PrinterSettings.Copies = (short)printCount;//打印份数
|
|
|
|
// var print = workbook.PrintDocument;
|
|
|
|
// print.PrinterSettings.PrinterName = printName;
|
|
|
|
// print.PrinterSettings.Copies = (short)printCount;//打印份数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print.Print(); |
|
|
|
} |
|
|
|
// print.Print();
|
|
|
|
//}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 打印京东箱唛
|
|
|
|