Message 1 of 4
How to Load family from excel spreadsheet

Not applicable
05-08-2015
02:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I just learned how to read a excel file and retrieve all data into a single string.
string Data = ""; using(ExcelPackage package = new ExcelPackage(new FileInfo(filename))) { ExcelWorksheet sheet = package.Workbook.Worksheets[1]; for (int row = 3; row < 9999; row++) { var thisValue = sheet.Cells[row, 1].Value; if (thisValue == null || thisValue.ToString() == "") break; for (int col = 1; col < 3; col++) { thisValue = sheet.Cells[row, col].Value; if (thisValue == null || thisValue.ToString() == "") break; Data += thisValue.ToString() + ","; } Data += Environment.NewLine; } } TaskDialog.Show("Excel Data: ", Data);
but How can I get a single string from each cell individuality by loop over each row?
for example I need string “Section” for the family symbol, and string “Type” for the category,
and use these 2 strings to load the family and its symbols. Like:
if (Type == "Beam") { FamilySymbol gotSymbol = null; String fileName = "Families path for structural framing family"; String name = Section; using (Transaction t = new Transaction(doc, "Load")) { t.Start(); Family family = null; if (doc.LoadFamilySymbol(fileName, name, out gotSymbol)) TaskDialog.Show("Status", name + " is loaded"); t.Commit(); } }
any suggestion or tips?
Thanks