• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache POI, deleting Excel Rows

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm simply just trying to get this program to delete a row after a button press. Using Apache POI and Excel.xlsx. Any help on what I'm doing wrong. I also tried it without add the shiftRow method.

Thanks

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What issue are you seeing?
Does it fail to delete the row, throw an exception, or something else?
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens/doesn't happen when this code is executed?  Could you TellTheDetails? (that's a link)
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is happening when you run this code, and what did you expect to happen instead? Can you post code that resembles an SSCCE (<- that's a link), especially showing how the file is opened and saved?

(Update: What they said :-) I didn't see the previous posts when I wrote this.)
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:What issue are you seeing?
Does it fail to delete the row, throw an exception, or something else?



Its not giving me any error, it just doesn't work.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, since the code you posted only contains two lines that use POI, but none of the crucial loading and saving of the sheet:

Can you post an SSCCE that demonstrates the issue, especially showing how the file is opened and saved?

 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/wiki/660111/Doesnt-Work-Useless

"Doesn't work" could mean:
1) Row is cleared but it doesn't get shifted up
2) No action is performed at all
3) Any number of things

Could you be more descriptive about exactly what doesn't work?
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:In that case, since the code you posted only contains two lines that use POI, but none of the crucial loading and saving of the sheet:

Can you post an SSCCE that demonstrates the issue, especially showing how the file is opened and saved?



This is a function of the code that is called by main. This is a big program for my job, so a lot of things here are/maybe not needed. I'm working on the rough draft. I'll iron it all out once everything works.

 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a start point, put some debug logging in there, even some simple println statements will be enough to show that the code shown is actually being executed.
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:https://coderanch.com/wiki/660111/Doesnt-Work-Useless

"Doesn't work" could mean:
1) Row is cleared but it doesn't get shifted up
2) No action is performed at all
3) Any number of things

Could you be more descriptive about exactly what doesn't work?



2) No action is performed at all.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does "done" print?
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Does "done" print?



Yes, I added it just to make sure that the line of code was working.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anthony Johnson wrote:
2) No action is performed at all.



But what does that mean?
What action do you expect to see?

All the above code shows is the removal of a row from the sheet, but there's nothing there to show us how you determine whether the row is removed.
Do you save the sheet and then check?
Is there something else you expect to see?

(And I missed you already had a println statement in there! )
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:

Anthony Johnson wrote:
2) No action is performed at all.



But what does that mean?
What action do you expect to see?

All the above code shows is the removal of a row from the sheet, but there's nothing there to show us how you determine whether the row is removed.
Do you save the sheet and then check?
Is there something else you expect to see?

(And I missed you already had a println statement in there! )



So I add a structure type/number to the construction notes, lets say row 11. If the person decides they don't want to use that structure type or used the wrong structure number, they can press "cancel". "Cancel" should remove delete that row. The reason that row needs to be deleted because below it is an empty row, waiting for the next structure to be added. If I can't get it to delete, a blank row will continue to be added. Then I will have more blank rows than I need. If that makes any sense.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it makes sense, I'm just not sure where exactly you are expecting to see the result of this deletion.

POI (for example) has no GUI, so is this your own GUI, in which case I would look at whether that side of things is going wrong.
Also, log what row it is removing in that action listener.  It's possible that is incorrect?

You might also want to do a quick test bit of code that opens an existing spreadsheet with a handful of rows, deletes one of them in the middle, and then saves it.  Look at the result just to see what POI does in the remove() operation and whether the shift is needed at all.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the row to remove the last row in the sheet?  If so, try:
 
Anthony Johnson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I got it. The file was closed before before it could write the updates. Its not working perfectly, but I think I can figure it out from here.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great!  Thanks for the update.
 
reply
    Bookmark Topic Watch Topic
  • New Topic