Question

I am building a ruby class/component to use in my Rails projects for creating reports/exports based on Excel .xlsx files. With the component, I can open a "template" .xlsx file, add data in rows to a sheet, save and then download the file to the user. It has been working well for several months now.

Now I need to take a pre-existing .xlsx file (think "form"), open it as a template, insert values in several of the cells, and then save and download to the user. For the most part, the process works. The one hitch is that one of the cells I am updating with data is within a range of cells that gets a SUM function applied to it. The problem: the SUM cell doesn't have the correct sum in it.

I've checked the cell both in Excel upon download, and also the underlying xml - the cell and its data is numeric - not text. When I try to manually recalc the sheet - nada. I can update one of the other cells in the range that is getting SUM'd, and it magically starts working - the SUM cell shows the proper total.

I read a post earlier today that mentioned removing the element from the total field in order to signal to Excel when the spreadsheet is opened that it should recalc - nope.

I'd really like to open source this component once I get this further along; I think it would be a BIG help to the Ruby community. Thanks in advance for any help!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top