Export BOM to Excel change Excel Sheet Name

Export BOM to Excel change Excel Sheet Name

KWarrenCA
Advocate Advocate
769 Views
3 Replies
Message 1 of 4

Export BOM to Excel change Excel Sheet Name

KWarrenCA
Advocate
Advocate

I created this iLogic to export a parts list in a drawing if it has a specific title. When it exports to the CSV file it also added the file name to the sheet name in excel. Is there a way to keep them all the same like "Sheet 1"? Our ERP software is going to import these csv files and it needs the sheet name to be the same for importing.

0 Likes
Accepted solutions (2)
770 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor
Accepted solution

You can add the options method to export  shown in this 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-to-export-parts-list-to-xls-u...

 

 

Below is the relevant code and also extra options remove as necessary. Table Name is the excel sheet name. 

     
' create a new NameValueMap object
oOptionsBOM = ThisApplication.TransientObjects.CreateNameValueMap

'specify an existing template file'to use For formatting colors, fonts, etc
oOptionsBOM.Value("Template") = "Y:\SUPPORT\Excel Templates\Purchasing BOM Template.xls"
 
'specify the columns to export         
oOptionsBOM.Value("ExportedColumns") = "ITEM#;QTY;PART#;MATERIAL;DESCRIPTION;COMMENTS;COM CODE;TOTAL WT."
 
'specify the start cell
oOptionsBOM.Value("StartingCell") = "B11"
 
'specify the XLS tab name'here the file name is used
oOptionsBOM.Value("TableName") = "BILL OF MATERIALS"

'choose to include the parts list title row'in this example "Ye Old List of Parts" is written to the StartingCell
oOptionsBOM.Value("IncludeTitle") = False          

'choose to autofit the column width in the xls file
oOptionsBOM.Value("AutoFitColumnWidth") = True

'get BOMrget folder path
oFolderBOM = Left(ExportPath, InStrRev(ExportPath, "\")) & "BOM"

'Check for the BOM folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolderBOM) Then
    System.IO.Directory.CreateDirectory(oFolderBOM)
End If
       
' export the Partslist to Excel with options
oPartslist.Export(oFolderBOM & "\" & ThisDoc.FileName(False) & ".xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptionsBOM)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 4

KWarrenCA
Advocate
Advocate

So that works when I export to an xls file format but if I try and export to csv file format it doesn't work. I know in Inventor there are no options to select when exporting to csv is this a limitation of the export?

0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor
Accepted solution


From a quick scan of stack overflow a csv file when opened through excel will always display the csv filename as the excel sheet name. So this is a limitation of those operations and not necessarily the BOM export. If your program is opening the csv file directly you won’t likely have this problem. So the next question is do you need just a constant filename? If that is the case change the filename of your BOM export. 

 

https://stackoverflow.com/questions/57628677/how-to-rename-sheet-name-different-from-file-name

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes