Hi all,
is there any way to read a single cell from an excel file?
I know there are some walkarrounds:
But in my case I have many values, and for the sake of simplicity and cleanliness it would be nice to have this option.
Thanks in advance =)
Hi all,
is there any way to read a single cell from an excel file?
I know there are some walkarrounds:
But in my case I have many values, and for the sake of simplicity and cleanliness it would be nice to have this option.
Thanks in advance =)
There are a couple custom packages that should be able to help you with this. I believe BumbleBee and Lunchbox both have nodes that allow you to specify a range.
Thanks for your suggestions Nick,
I had already tried BlumbleBee and now I tried Lunchbox. None of them works. You must take at least two cells.
Of course, a simple python script can solve it, what is what I did. But would be great to add this capability to this kind of packages.
Can you show what you tried and what worked with bumblebee?
Hi @Juan.dyn
Try this:
import clr
clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
from Microsoft.Office.Interop import Excel
ex = Excel.ApplicationClass()
ex.DisplayAlerts = False
filepath = IN[0]
workbook = ex.Workbooks.Open(filepath)
ws = workbook.Worksheets[1]
range = ws.Range[str(IN[1])]
cell_value = []
for cell in range.Columns:
cell_value.append(cell.Value2)
OUT = cell_value
Hi @Kulkul,
thanks a lot! That works!
I am actually developing some optimization using a FEM application (Sofistik), which gives me the results I need (weight, stress, displacement) in a very unique way. Therefore I modified your script, so it takes a given cell range for each worksheet.
This is the resulting script:
Which applies to this kind of excel book:
import clr
clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
from Microsoft.Office.Interop import Excel
ex = Excel.ApplicationClass()
ex.DisplayAlerts = False
filepath = IN[0]
workbook = ex.Workbooks.Open(filepath)
# IN[1] list with cell range specification:
cell_range= IN[1]
cell_value = []
for i, ws in enumerate(workbook.Worksheets):
cell_value.append(ws.Range[cell_range[i-1]].Value2)
close=workbook.Close(True)
close=ex.Quit
#First worksheet is null
del cell_value[0]
OUT=cell_value
Thanks again for your help =)