|
|
|
|
@ -1514,5 +1514,104 @@ namespace FactorySystemCommon
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool ExportBomlist(string templatePath, string savePath, string testCode, string userName, string productNumber, string productName, string applyTime, List<Dictionary<string, object>> bomList)
|
|
|
|
|
{
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(templatePath))
|
|
|
|
|
{
|
|
|
|
|
status = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileStream templateFile = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
|
|
|
|
|
FileStream saveFile = new FileStream(savePath, FileMode.Create);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IWorkbook workbook = null;
|
|
|
|
|
workbook = new XSSFWorkbook(templateFile);
|
|
|
|
|
|
|
|
|
|
ISheet sheetBomList = workbook.GetSheetAt(0);
|
|
|
|
|
ISheet sheetApplyHistory = workbook.GetSheetAt(1);
|
|
|
|
|
|
|
|
|
|
IRow row = sheetBomList.GetRow(2);
|
|
|
|
|
|
|
|
|
|
// 试验号
|
|
|
|
|
ICell testCodeCell = row.GetCell(1);
|
|
|
|
|
testCodeCell.SetCellValue(testCode);
|
|
|
|
|
|
|
|
|
|
// 技术人员
|
|
|
|
|
ICell userNameCell = row.GetCell(6);
|
|
|
|
|
userNameCell.SetCellValue(userName);
|
|
|
|
|
|
|
|
|
|
// 生产数量(g)
|
|
|
|
|
ICell productNumberCell = row.GetCell(8);
|
|
|
|
|
productNumberCell.SetCellValue(productNumber);
|
|
|
|
|
|
|
|
|
|
row = sheetBomList.GetRow(4);
|
|
|
|
|
|
|
|
|
|
// 产品名称
|
|
|
|
|
ICell productNameCell = row.GetCell(1);
|
|
|
|
|
productNameCell.SetCellValue(productName);
|
|
|
|
|
|
|
|
|
|
// 申请日期
|
|
|
|
|
ICell applyTimeCell = row.GetCell(8);
|
|
|
|
|
applyTimeCell.SetCellValue(applyTime);
|
|
|
|
|
|
|
|
|
|
if (bomList != null)
|
|
|
|
|
{
|
|
|
|
|
int newRowCount = bomList.Count;
|
|
|
|
|
int bomColumnCount = bomList[0].Count;
|
|
|
|
|
|
|
|
|
|
sheetBomList.ShiftRows(7, 10, newRowCount);
|
|
|
|
|
IRow tmpRow = sheetBomList.GetRow(7 + newRowCount);
|
|
|
|
|
|
|
|
|
|
ICell sourceCell = null;
|
|
|
|
|
ICell targetCell = null;
|
|
|
|
|
|
|
|
|
|
for (int rowNo=7; rowNo<7+newRowCount; rowNo++)
|
|
|
|
|
{
|
|
|
|
|
IRow targetRow = sheetBomList.CreateRow(rowNo);
|
|
|
|
|
|
|
|
|
|
for (int cellNo = tmpRow.FirstCellNum; cellNo < tmpRow.LastCellNum; cellNo++)
|
|
|
|
|
{
|
|
|
|
|
sourceCell = tmpRow.GetCell(cellNo);
|
|
|
|
|
if (sourceCell == null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
targetCell = targetRow.CreateCell(cellNo);
|
|
|
|
|
targetCell.CellStyle = sourceCell.CellStyle;
|
|
|
|
|
targetCell.SetCellType(sourceCell.CellType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targetRow.GetCell(0).SetCellValue(bomList[rowNo - 7]["原料编号"].ToString());
|
|
|
|
|
targetRow.GetCell(1).SetCellValue(bomList[rowNo - 7]["SAP编号"].ToString());
|
|
|
|
|
targetRow.GetCell(2).SetCellValue(bomList[rowNo - 7]["原料名称"].ToString());
|
|
|
|
|
targetRow.GetCell(3).SetCellValue(bomList[rowNo - 7]["稀释液"].ToString());
|
|
|
|
|
targetRow.GetCell(4).SetCellValue(bomList[rowNo - 7]["稀释溶剂"].ToString());
|
|
|
|
|
targetRow.GetCell(5).SetCellValue(bomList[rowNo - 7]["标准数量"].ToString());
|
|
|
|
|
targetRow.GetCell(6).SetCellValue(bomList[rowNo - 7]["投料数量"].ToString());
|
|
|
|
|
targetRow.GetCell(7).SetCellValue(bomList[rowNo - 7]["备注"].ToString());
|
|
|
|
|
targetRow.GetCell(8).SetCellValue(bomList[rowNo - 7]["可替换香基"].ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 另存文件
|
|
|
|
|
workbook.Write(saveFile);
|
|
|
|
|
status = true;
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
status = false;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
templateFile.Close();
|
|
|
|
|
saveFile.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|