GoExcel not recongnizing Sheet

GoExcel not recongnizing Sheet

kylegT2ZZF
Contributor Contributor
289 Views
6 Replies
Message 1 of 7

GoExcel not recongnizing Sheet

kylegT2ZZF
Contributor
Contributor

I have some iLogic code where I'm trying to output a list to excel.  When I try and use the GoExcel command it gives me an error that it can't find Sheet1 in my table.  I have the excel table in the same location as my assembly so I'm not sure what's going wrong.  I've attached an example dataset to try out.

0 Likes
290 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Hi @kylegT2ZZF 

Couod you attach the code your using to this post? Press the </> button and paste the code from the ilogic editor. Once we see the code we can review if there is error in it's construction. Can you also paste any error messages your seeing? 

 

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 7

kylegT2ZZF
Contributor
Contributor

/

i = 20 ft
j = 2
While i < 70 ft
	Length = i
	Parameter("Lengths:1", "Length") = Length
	InventorVb.DocumentUpdate()
	Total_Length = Parameter("BC:1", "Length") + Parameter("TC1:1", "Length") + Parameter("TC2:1", "Length")
	a = "A" & j
	b = "B" & j
	i = i + 1
	j = j + 1
	GoExcel.CellValue("Lengths.xls", "Sheet1", a) = Length
	GoExcel.CellValue("Lengths.xls", "Sheet1", b) = Total_Length
End While

 

 

kylegT2ZZF_0-1734972872398.png

 

 

0 Likes
Message 4 of 7

kylegT2ZZF
Contributor
Contributor

All the files in the attached zip also have all of my code and the excel file I'm trying to use.

0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor

Can you check the file type your using is .xlsx. or matching the excel workbook your using? .xls is an older file type not commonly used today. 

Also I see the cells are not correctly referenced it should be "A1" etc

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

kylegT2ZZF
Contributor
Contributor

You got the file extension right, I'm using xlsx while the template from iLogic defaults to xls.  When I switched it started running but as you noted my cells are not referencing.  I'm wanting to indicate a range of cells and thought I could do that by indexing against a number that is increasing but that doesn't seem to work.  Any ideas how to get it to add the total length in order down the excel column?

0 Likes
Message 7 of 7

chaines59GWR
Contributor
Contributor

You need to use the full path. Also I don't think calling out "a" will work.

 

I would do a loop like

For Each oItem as String in GoExcel.CellValues("filename.xls", "Sheet1", "A2", "A100")

    Logger.info(oItem)

Next

 

i = 20 ft
j = 2

Dim ExcelPath as String = "C:\Wherever\"
While i < 70 ft Length = i Parameter("Lengths:1", "Length") = Length InventorVb.DocumentUpdate() Total_Length = Parameter("BC:1", "Length") + Parameter("TC1:1", "Length") + Parameter("TC2:1", "Length") a = "A" & j b = "B" & j i = i + 1 j = j + 1 GoExcel.CellValue(ExcelPath & "Lengths.xls", "Sheet1", a) = Length GoExcel.CellValue(ExcelPath & "Lengths.xls", "Sheet1", b) = Total_Length End While

 

0 Likes