I have an existing xlsx file that I am trying to write data to programatically. Is there any modern solution to this for ruby? Also looked into the Google Sheets API but it's only Java and .Net.
I've searched quite a bit, and so far have checked out the following gems with no luck:
https://github.com/roo-rb/roo
https://github.com/randym/axlsx
https://github.com/weshatheleopard/rubyXL
https://github.com/cxn03651/write_xlsx
In the meantime it seems my best solution is to write to CSV, then import the CSV into the xlsx file. But it's tough to do that programmatically in the future.
Any help would be appreciated, thanks.
Related
I want to read from and write to the same EXCEL file (file.xls) using Ruby. I tried to use Roo gem which doesn't allow to write to the file. Now I am using Spreadsheet gem, but I can't update existing data in the same excel file.
Is it possible to read from and write to the same EXCEL file without change in macros using Ruby?
Here's a similar post that received an answer: I want to edit a wellformatted excel file with ruby
Basically, you may want to check out win32ole: http://davidsulc.com/blog/2011/03/27/using-ruby-and-win32ole-to-manipulate-excel/
I was unable to make Roo read and write from the same file. This could be due to the fact that Roo creates a temporary file before it writes. Writing to a new file is cleaner, easier and supported. I have the data that I want to read from in my project under db/data/import, then I write to db/data/export and everything got way easier once I went with this approach.
I'm looking for a way to reading and writing on same excel file in ruby. I saw a this topic but the suggestions doesn't work for me.
I tried to use Roo gem, but this not allow to write. I tried to use the Spreadsheet gem too, but this doesn't read Xlsx files.
Is there a way to reading and write on same excel file in ruby?
try rubyXL
Ruby lib for reading/writing/modifying .xlsx and .xlsm files
I need to create a text file for a game designer to edit variables in my C# script. I would like to be able to write the variable in the text file and the designer can put in a value and hten it would change in my script.
However, after much searching I have not been able to find a solution to my problem and was hoping someone with some experience in this method could help me.
I'm using Visual Studio for writing my scripts and the designer would require Notepad.
Thanks,
Chris
You can try using this class that will allow you to use ini files to hold your configuration.
I'm assuming your designer wouldn't like to use XML (which is the .NETy way of doing things); making humans edit XML is a form of torture anyway.
Here's the link to the CodeProject page: An INI file handling class using C#.
You can also use some other (relatively simple) format like JSON if ini files are too flat for you.
Is there a way to use Ruby to delete columns in an Excel spreadsheet by name (i.e. the value in the first row of the spreadsheet) on a Windows machine?
Background if you want it:
I am going to be receiving a large number of Excel spreadsheets on a regular basis. Some of these spreadsheets will contain columns that need to be deleted. I will know the names (first-row values) of the columns, but their positions in their respective spreadsheets will change from time to time, so I won't be able to automatically refer to the columns by letter. I would really like to be able to automate this process...
POI is the Apache project to create a library for reading MS Office files; it appears they have Ruby extensions. I have never used it before, but the code looks easy enough to understand. Good luck! Check it out here
You probably want to use the WIN32OLE library, built into the standard library on Windows. There's an example in PickAxe about using Microsoft Excel through the WIN32OLE library, and other examples here. You just need to learn how to use the Excel COM API to make the particular changes you're interested in.
Is there a way to generate Excel spreadsheets with Perl on Linux so that I can open the spreadsheet on Windows and it creates native Excel graphics? I know that there are libs to draw graphics but all libs I know simply insert a picture to the Excel which looks weird when I open the spreadsheet on Windows. So I wondering is there a way to do it better? Possibly I could embed a VB script or something so that it creates a graphics automatically when I open the spreadsheet on Windows? The original spreadsheet must be generated on Linux so there are no ways to use OLE or some other Windows-only technology.
Thanks guys! Spreadsheet::WriteExcel seems to be a good solution. Did not understand at the first glance if it allows to change dimensions of data or it is hardcoded in a template file (10 points for example, no more, no less). Does anyone know?
If anyone knows another way of doing my task, please post it here. I'm interested in comparing of different solutions and select the best.
Yes, Spreadsheet::WriteExcel has a embed_chart($row, $col, $filename, $x, $y, $scale_x, $scale_y) function which lets you do this.
Spreadsheet::WriteExcel allows you to insert charts from existing files (with some caveats).
See, the following sub-document on Spreadsheet::WriteExcel Charts and the examples files in the distro, such as this one.
P.S. I am the author of that module.
Try Spreadsheet::WriteExcel.