SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast gecastill's Avatar
    Join Date
    May 2005
    Location
    Virginia US
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to delete [not clear] rows in a spreadsheet using Apache POI [workbook]?

    http://poi.apache.org/
    The POI project consists of APIs for manipulating various file formats based upon Microsoft's OLE 2 Compound Document format, and Office OpenXML format, using pure Java. In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. POI is your Java Excel solution (for Excel 97-2007). However, we have a complete API for porting other OLE 2 Compound Document formats and welcome others to participate.


    When I remove a row from the spreadsheet using Apache POI the cell values in the row get clear and the row still exist with empty cells.

    This is what I execute in the code HSSFSheet.removeRow(HSSFRow)

    How can I completely remove the row from the worksheet [workbook]?

    Please advise, thanks.
    Best Regards,
    Gibran E Castillo

  2. #2
    SiteP0int Weazle hooknc's Avatar
    Join Date
    Dec 2004
    Location
    Socialist Republic of Boulder
    Posts
    937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    POI can be quite difficult to work with...

    That being said...

    I think the behavior that POI is doing is correct.

    What happens when you delete a column in a normal Excel spread sheet?

    In the version of Excel (2007) I have the row is deleted, but all the other rows below that row are moved up and 24 is now referred to as 23.

    Best of Luck.
    baby steps... baby steps...

  3. #3
    SitePoint Enthusiast gecastill's Avatar
    Join Date
    May 2005
    Location
    Virginia US
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hooknc: Understood.
    Best Regards,
    Gibran E Castillo

  4. #4
    SitePoint Enthusiast gecastill's Avatar
    Join Date
    May 2005
    Location
    Virginia US
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to use HSSFSheet.shiftRows(int startRow, int endRow, int n);

    public void shiftRows(int startRow,
    int endRow,
    int n)

    Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around. Calls shiftRows(startRow, endRow, n, false, false);

    Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

    Specified by:
    shiftRows in interface Sheet

    Parameters:
    startRow - the row to start shifting
    endRow - the row to end shifting
    n - the number of rows to shift

    So far no luck, I think I am close. Any hints will be appreciated.

    Thanks.
    Best Regards,
    Gibran E Castillo

  5. #5
    SitePoint Enthusiast gecastill's Avatar
    Join Date
    May 2005
    Location
    Virginia US
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out, this works HSSFSheet.shiftRows(int startRow, int endRow, int n);

    Cheers!
    Best Regards,
    Gibran E Castillo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •