Page 1 of 1

Need help in adding a cell with "abc"

PostPosted: Sat Apr 21, 2012 3:00 am
by aherrera
Hi all,

I can create an Excel Workbook with no problems if I'm creating a cell with "1234" in it.
I used the example from the following URL:

Code: Select all
   private static void addContent(WorksheetPart sheet) throws Exception {
      // minimal content already present
      SheetData sheetData = sheet.getJaxbElement().getSheetData();
      // add stuff
      Row row = Context.getsmlObjectFactory().createRow();
      Cell cell = Context.getsmlObjectFactory().createCell();
      Cell cell2 = Context.getsmlObjectFactory().createCell();
      cell2.setV("ABC"); ///// doesn't like this String value, but is OK with the "1234" as above.
      System.out.println("cell 2");
      System.out.println("cell 1");

In the code snip above, adding first cell "cell" had no problems, I added "cell2" with no problems using a different numeric value. But, when I changed "cell2" to be simply "ABC" for the value, it gives me grief, MS Excel gives me a warning stating it had to fix the sheet, then it shows the values in the cells as I expect them to be.

I would like to get rid of the MS Excel warning and ensure that the cells with text have no problems as do the cells with numeric-text do.

Any ideas?

I tried to make sense out of the following two links within the forum, but failed to grasp as to what really is required to just add "ABC" in and have it work in MS Excel without any alerts showing up.

Do I really need this SharedStrings deal? If so, can someone assist me with, perhaps, provide a working sample that uses the SharedStrings? The code snip provided in the second URL given above didn't quite make sense to me. Seemed like a lot to go through to just add "ABC". Thus, I tried to follow it, but couldn't figure out how to apply it to my own code. Therefore, a working sample would help greatly in understanding how it is to be put together.

Thank you!


Re: Need help in adding a cell with "abc"

PostPosted: Tue Apr 24, 2012 3:08 am
by herolsen
Hi -- please see the updated post (xlsx-java-f15/cells-with-character-values-t874.html); I put in a comment on how to use inline strings so that you don't have to deal with shared.xml. That might be helpful.

Re: Need help in adding a cell with "abc"

PostPosted: Thu Apr 26, 2012 10:18 pm
by jason
Yep, there is another post somewhere in the forum which references the video ... heets.aspx

Sorry you had to rediscover that... I've updated the sample code with references to this info