Results 1 to 18 of 18
Like Tree3Likes
  • 1 Post By Tolls
  • 2 Post By bolbi123456

Thread: Editing specific (existing) excel cells

  1. #1
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Editing specific (existing) excel cells

    i am trying to send information entered from the user in a java application into existing cells in a worksheet. I have the jxl package, and have not tried api. Can anyone provide a solution?

    current code:

    private static File file = new File("AutoInvoice.xlsx");
    public InvoiceModifier()
    {

    }

    public static void editInvoice(String address)
    {
    try
    {
    FileInputStream fis=new FileInputStream(file);
    Workbook workbook = Workbook.getWorkbook(fis);
    WritableWorkbook copy = Workbook.createWorkbook(new File("newinvoice.xlsx"), workbook);

    WritableSheet sheet = copy.getSheet(0);
    WritableCell cell = sheet.getWritableCell(6,0);


    if (cell.getType() == CellType.LABEL)
    {
    Label l = (Label)cell;
    l.setValue(address);
    }

    // All cells modified/added. Now write out the workbook
    copy.write();
    copy.close();
    workbook.close();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,405
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    You didn't bother to reply to mcajavaprogramer's response in your earlier thread. Why should we expect any better behavior this time round?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,405
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Quote Originally Posted by bolbi123456 View Post
    I have the jxl package, and have not tried api. Can anyone provide a solution?
    First you need to tell us why you have 'not tried API'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    What happens when you use the code above?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    a write exception is thrown, because the data type can not be specified. i have checked all of the data types in the excel spreadsheet and it matches,
    the part that skips while debugging is
    if (cell.getType() == CellType.LABEL)

  6. #6
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    -darryl, i have searched and just wanted to know if it was possible to edit cells with jxl.
    thanks

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Post the full exception plus stack trace and highlight the line it occurs on.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    managed to get the one exception fixed, however i get a new error message that i can find no solutions to online.
    while reading the if statement, the error show is
    "Warning: Text on sheet "Simple with Sales Tax" not supported - omitting"
    iv noticed a few others with the same problem but there have been no replies on related threads. thanks to anyone with an answer

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    What does the code look like now (and please use [code] tags [/code])?
    Also give us the full error/warning including any stack trace associated with it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    managed to get the one exception fixed, however i get a new error message that i can find no solutions to online.
    while reading the if statement, the error shown is

    "Warning: Text on sheet "Simple with Sales Tax" not supported - omitting"
    it is the only thing written with printstacktrace

    iv noticed a few others with the same problem but there have been no replies on related threads. thanks to anyone with an answer

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,405
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Repeating your earlier post and not replying to the question posed by Tolls isn't going to help you get help.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  12. #12
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    the code is the same as earlier posted.. the only thing changed is the file extension, changed from "xlsx" to "xlt".
    the only error shown in the terminal is
    "Warning: Text on sheet "Simple with Sales Tax" not supported - omitting"

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    'xlt'?
    I assume you mean 'xls'.
    Not knowing what your Excel sheet looks like I can only guess that there is something on it that JExcel does not support.
    I would start by paring the sheet down to a basic sheet with cells and data and the start adding in the fancier bits (including any formula cells). You should eventually find the thing that it's complaining about.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,405
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    XLT is the extension for an Excel template.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Oh right.
    Then I would check what limitations JExcel has around templates (and do the paring down above as well).
    Assuming that warning is coming from JExcel (where else would it be coming from?) then it's pretty clear that there's something there it doesn't support.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  16. #16
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    ok thanks alot everyone, ill try recreating the excel sheet myself and post the results.

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default Re: Editing specific (existing) excel cells

    Another option is to try the same sort of thing with Apache POI.
    Fubarable likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  18. #18
    bolbi123456 is offline Member
    Join Date
    May 2012
    Posts
    10
    Rep Power
    0

    Default Re: Editing specific (existing) excel cells

    tried for hours to get it working with jxl, with no success. downloaded the apache poi jar file and followed a few online starters, i managed to get the sheet edited within about an hour.
    lesson - when editing spreadsheets, use POI!
    thanks everyone
    Fubarable and DarrylBurke like this.

Similar Threads

  1. Replies: 0
    Last Post: 11-17-2011, 09:33 AM
  2. Stop editing jtable cells programatically
    By krimen in forum AWT / Swing
    Replies: 4
    Last Post: 11-09-2011, 02:35 AM
  3. Editing java app from existing app
    By illuminator3 in forum Java Applets
    Replies: 5
    Last Post: 01-20-2011, 09:37 PM
  4. Problem editing existing UI
    By sargehendricks in forum AWT / Swing
    Replies: 3
    Last Post: 04-23-2009, 06:29 PM
  5. Replies: 0
    Last Post: 11-06-2007, 06:58 AM

Posting Permissions

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