How to get the name of work sheet in a excel file using win32ole gem with ruby on rails?

StackOverflow https://stackoverflow.com/questions/21751414

  •  11-10-2022
  •  | 
  •  

Pergunta

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..

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top