Save file name in excel file.
This commit is contained in:
@@ -313,10 +313,8 @@ namespace ExportDXF.Forms
|
|||||||
if (worker.CancellationPending)
|
if (worker.CancellationPending)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
item.ItemNo = prefix + item.ItemNo;
|
var fileName = GetFileName(item);
|
||||||
|
var savepath = Path.Combine(savePath, fileName + ".dxf");
|
||||||
var fileName = item.ItemNo + ".dxf";
|
|
||||||
var savepath = Path.Combine(savePath, fileName);
|
|
||||||
var model = item.Component.GetModelDoc2() as ModelDoc2;
|
var model = item.Component.GetModelDoc2() as ModelDoc2;
|
||||||
var part = model as PartDoc;
|
var part = model as PartDoc;
|
||||||
|
|
||||||
@@ -351,7 +349,11 @@ namespace ExportDXF.Forms
|
|||||||
if (part == null)
|
if (part == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SavePartToDXF(part, config, savepath);
|
if (SavePartToDXF(part, config, savepath))
|
||||||
|
{
|
||||||
|
item.FileName = Path.GetFileNameWithoutExtension(savepath);
|
||||||
|
}
|
||||||
|
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +370,20 @@ namespace ExportDXF.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetFileName(Item item)
|
||||||
|
{
|
||||||
|
var prefix = prefixTextBox.Text.Replace("\"", "''");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(item.ItemNo))
|
||||||
|
{
|
||||||
|
return prefix + item.PartName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return prefix + item.ItemNo.PadLeft(2, '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string ChangePathExtension(string fullpath, string newExtension)
|
private string ChangePathExtension(string fullpath, string newExtension)
|
||||||
{
|
{
|
||||||
var dir = Path.GetDirectoryName(fullpath);
|
var dir = Path.GetDirectoryName(fullpath);
|
||||||
@@ -451,25 +467,30 @@ namespace ExportDXF.Forms
|
|||||||
{
|
{
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
var row = i + 2;
|
var row = i + 2;
|
||||||
|
var col = 1;
|
||||||
|
|
||||||
partsSheet.Cells[row, 1].Value = item.ItemNo;
|
partsSheet.Cells[row, col++].Value = item.ItemNo;
|
||||||
partsSheet.Cells[row, 2].Value = item.Quantity;
|
partsSheet.Cells[row, col++].Value = item.FileName;
|
||||||
partsSheet.Cells[row, 3].Value = item.Description;
|
partsSheet.Cells[row, col++].Value = item.Quantity;
|
||||||
partsSheet.Cells[row, 4].Value = item.PartNo;
|
partsSheet.Cells[row, col++].Value = item.Description;
|
||||||
|
partsSheet.Cells[row, col++].Value = item.PartName;
|
||||||
|
|
||||||
if (item.Thickness > 0)
|
if (item.Thickness > 0)
|
||||||
partsSheet.Cells[row, 5].Value = item.Thickness;
|
partsSheet.Cells[row, col].Value = item.Thickness;
|
||||||
|
col++;
|
||||||
|
|
||||||
partsSheet.Cells[row, 6].Value = item.Material;
|
partsSheet.Cells[row, col++].Value = item.Material;
|
||||||
|
|
||||||
if (item.KFactor > 0)
|
if (item.KFactor > 0)
|
||||||
partsSheet.Cells[row, 7].Value = item.KFactor;
|
partsSheet.Cells[row, col].Value = item.KFactor;
|
||||||
|
col++;
|
||||||
|
|
||||||
if (item.BendRadius > 0)
|
if (item.BendRadius > 0)
|
||||||
partsSheet.Cells[row, 8].Value = item.BendRadius;
|
partsSheet.Cells[row, col].Value = item.BendRadius;
|
||||||
|
col++;
|
||||||
}
|
}
|
||||||
|
|
||||||
partsSheet.Column(1).AutoFit();
|
partsSheet.Column(2).AutoFit();
|
||||||
|
|
||||||
workbook.Calculate();
|
workbook.Calculate();
|
||||||
pkg.Save();
|
pkg.Save();
|
||||||
@@ -583,10 +604,10 @@ namespace ExportDXF.Forms
|
|||||||
{
|
{
|
||||||
items.Add(new Item
|
items.Add(new Item
|
||||||
{
|
{
|
||||||
PartNo = table.DisplayedText[rowIndex, partNoColumnIndex],
|
PartName = table.DisplayedText[rowIndex, partNoColumnIndex],
|
||||||
Quantity = int.Parse(table.DisplayedText[rowIndex, qtyColumnIndex]),
|
Quantity = int.Parse(table.DisplayedText[rowIndex, qtyColumnIndex]),
|
||||||
Description = table.DisplayedText[rowIndex, descriptionColumnIndex],
|
Description = table.DisplayedText[rowIndex, descriptionColumnIndex],
|
||||||
ItemNo = table.DisplayedText[rowIndex, itemNoColumnIndex].PadLeft(2, '0'),
|
ItemNo = table.DisplayedText[rowIndex, itemNoColumnIndex],
|
||||||
Component = distinctComponents.First()
|
Component = distinctComponents.First()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -623,8 +644,7 @@ namespace ExportDXF.Forms
|
|||||||
|
|
||||||
list.Add(new Item
|
list.Add(new Item
|
||||||
{
|
{
|
||||||
ItemNo = name,
|
PartName = name,
|
||||||
PartNo = name,
|
|
||||||
Quantity = group.Count(),
|
Quantity = group.Count(),
|
||||||
Component = component
|
Component = component
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ namespace ExportDXF
|
|||||||
{
|
{
|
||||||
public string ItemNo { get; set; }
|
public string ItemNo { get; set; }
|
||||||
|
|
||||||
public string PartNo { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|
||||||
|
public string PartName { get; set; }
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user