Ask Ben: Updating An Excel Document More Than Once With The POI Utility

Posted August 6, 2008 at 9:04 AM by Ben Nadel

Tags: ColdFusion, Ask Ben

Does this utility [POI] include a way to continue to add data to the spread sheet after the first addition? Thanks again for all of your help.

Yes it does. Well, sort of. The POI utility ColdFusion custom tags allows you to dictate a "template" to be used. This template is an existing Excel file whose contents are read in without alteration. Then, you can make changes to the existing Excel data as you see fit. So, if you treat each file as a template, you can continue to make as many updates as you want.

What the POI ColdFusion custom tags do NOT do is pick up where they left off. So for example, if you wrote 100 rows then closed the file. Then opened it again and wrote 100 rows - you'd end up with a file that has 100 rows in it, not 200. If your intent is to have 200 rows, then perhaps we can update the functionality of the tags. Because the "Index" attribute of the rows and cells allows you to manually output data in position you like, I want to avoid the idea of an "append" action:

  • <poi:sheet action="append">

Besides, if you really are using the POI custom tags to populate a formatted template, you aren't really appending.

What about something like a CALLER-scoped variable that has information about the read-in Excel file? Something like this:

  • <poi:sheet>
  • <poi:row index="#(POI.InitialRowCount + 1)#">
  • <poi:cell ... />
  • </poi:row>
  • </poi:sheet>

Here, in the context of the current Sheet, POI.InitialRowCount stores the number of rows that were already in the Excel file at the time of instantiation. This way, you could tell the "Index" tracking to pick up after the last row of the read-in Excel file.

Do you think something like that might be useful?



Reader Comments

Ana
Aug 8, 2008 at 5:41 PM // reply »
3 Comments

In most cases this solution would be perfect. In my case the row numbers are part of the template design (excel row numbering is turned off for aesthetic purposes), therefore, when the excel file is read there will be data in Column 1 row 1 thru ...


Aug 8, 2008 at 6:30 PM // reply »
11,246 Comments

@Ana,

I am not sure that I am following you exactly. Are you saying that your using row numbers in a way that this would not work?


Ana
Aug 12, 2008 at 6:59 PM // reply »
3 Comments

Yes. From my understanding of what you wrote is that the IntitialRowCount() would check the for the last row that has data. Is that correct? If so the author of the excel file as placed row numbers in column1:row1 with a style. That's why I think what you are saying wouldn't work for me.


Mar 29, 2010 at 1:39 PM // reply »
1 Comments

Ben, was anything ever done with the "InitialRowCount". This would be perfect for a project that I'm working on. That or the ability to append to an excel file! :D How would I go about this?


Apr 21, 2010 at 10:04 AM // reply »
11,246 Comments

@Steve,

I haven't done much with this project in a while. At some point, I keep meaning to make some time really give it a solid upgrade. Just never enough time!


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 24, 2013 at 11:21 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, Ha ha, let's us never speak of justifying "##" notation again :P ... read »
May 24, 2013 at 11:18 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Ah, so it was indeed how I vaguely remembered it to be: A direct assignment value = users.id[ i ] causes value to retain the sticky datatype of the query column. Although unnecessary in ... read »
May 24, 2013 at 9:11 AM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Brandon, Hi, No, I haven't been able to do that. I have just kept it as it is. ... read »
May 23, 2013 at 9:52 PM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Muhmmadibn Did you figure out a solution to launching PDFs? I am running into the same issues myself. There is no way to close the PDF or go back once you launch it. Thanks in advance! ... read »
May 23, 2013 at 6:06 PM
The Girl Who Broke My Heart, And Made Me A Better Person
Good day,ladies and gentle men, my name is Dr AMADI the great spell caster in Africa, i have help so many people for different kind of problems,who say there is no solution to problems on earth, that ... read »
May 23, 2013 at 4:26 PM
ColdFusion QueryAppend( qOne, qTwo )
@Heather, Glad people are still getting value out of this! ... read »
May 23, 2013 at 3:49 PM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, I meant the code at the bottom (not the video). I did try to experiment with an intermediary variable, like: value = users.id[ i ]; arrayContains( userIDs, value ); ... but t ... read »
May 23, 2013 at 11:06 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Are you talking about As Number: YES As String: YES As Java: YES? If so, that's with 3 different ways of referencing the constant 1, not users.id[1]. Query object references(*) are what seem ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools