Hi How can I fetch the name of first excel sheet in my excel file using the gem win32ole?? I want to validate an excel file based on the name of the first sheet..

I'm using ROR 3..

有帮助吗?

解决方案

I got it! it was quite simple

WIN32OLE.ole_initialize
excel_app = WIN32OLE.new('Excel.Application')
workbook = excel_app.Workbooks.Open(path)
worksheet1 = workbook.Worksheets(1)
ws_name = worksheet1.name
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top