Andrew, I forgot to mention to basic approaches.
1. Create the before and after state of the desired document in your ODF application of your choice. Save the document. Take a look at the XML you need to create. 2. What I suggest and I am not sure if it exists is to go in the W3C DOM tree to the previous row and clone it, which is basic DOM functionality: https://xerces.apache.org/xerces-j/apiDocs/org/w3c/dom/Node.html#cloneNode(boolean) Now it should help! Svante ᐧ Am Mo., 12. Nov. 2018 um 18:47 Uhr schrieb Svante Schubert < [email protected]>: > Hi Andrew, > > Simple API is using underneath ODFDOM, which represents an ODF Document. > The ODF Document is at least several zipped XML files. > For instance, each XML of the content.xml is represented by a W3C DOM > node. Therefore if you like to duplicate a row, being represented by a > <table:table-row> element you may also duplicate the TableTableElement > object. > > I guess the best way to proceed is to alter an existing test case of > ODFDOM or Simple API. > > Hopefully this could help you! > Svante > ᐧ > > Am Mo., 12. Nov. 2018 um 02:24 Uhr schrieb Andrew Willerding < > [email protected]>: > >> Hi Svante, >> >> Thank you for your reply. I'm finding it difficult to find out what I >> need to Google to follow the path you suggested below. Do you have some >> examples or web sites or books that you could recommend as a good >> starting point? >> >> Thanks, >> >> Andrew >> >> On 2018-11-10 4:32 a.m., Svante Schubert wrote: >> > Hi Andrew, >> > >> > likely Simple API has not implemented that feature, but Simple API >> relies >> > on ODFDOM and that uses W3C DOM, so you might consider to clone/copy the >> > previous table row. >> > Best is to take a look into the ODF XML to check if there are any IDs >> you >> > might need to adjust. >> > >> > Have a nice weekend, >> > Svante >> > >> > PS: I am personally using ODFDOM only, for instance currently I am >> > extracting table data from an EU specification to generate source code >> from. >> > >> > >> > Am Mi., 7. Nov. 2018 um 22:37 Uhr schrieb Andrew Willerding < >> > [email protected]>: >> > >> >> Hi, >> >> >> >> I have an existing table that I am appending rows to and I want the new >> >> rows to have the same font, alignment, etc as the rows previous to the >> >> additions but I'm finding that the new rows appear in the default >> >> document font style. >> >> >> >> He's a snippet of code I've used to try to manipulate the cell fonts. >> >> >> >> Cell cellItem = >> >> newRow.getCellByIndex(cellIndex++); >> >> cellItem.setStringValue(cell); >> >> if (firstRow != null) { >> >> System.out.println("Cell=" + >> >> firstRow.getCellByIndex(cellIndex - 1).getStringValue()); >> >> // System.out.println("Cell=" + >> >> firstRow.getCellByIndex(cellIndex - >> >> 1).getHorizontalAlignmentType().getAlignmentString()); >> >> System.out.println("Cell=" + >> >> firstRow.getCellByIndex(cellIndex - 1).getCellStyleName()); >> >> System.out.println("Cell=" + >> >> firstRow.getCellByIndex(cellIndex - 1).getStyleHandler()); >> >> // >> >> cellItem.setHorizontalAlignment(firstRow.getCellByIndex(cellIndex - >> >> 1).getHorizontalAlignmentType()); >> >> //cellItem.setFont(firstRow.getCellByIndex(cellIndex -1).getFont()); >> >> //cellItem.getFont().setSize(firstRow.getCellByIndex(cellIndex >> >> -1).getFont().getSize() - 2); >> >> cellItem.getStyleHandler().setFont(firstRow.getCellByIndex(cellIndex - >> >> 1).getStyleHandler().getFont(Document.ScriptType.WESTERN)); >> >> // >> >> cellItem.setCellStyleName(firstRow.getCellByIndex(cellIndex - >> >> 1).getCellStyleName()); >> >> } >> >> >> >> Except for the actual value of the cell, what prints out with the >> >> System.out statements is not the actual font, font size, etc of the >> cell. >> >> >> >> Is this a bug or am I not accessing and setting the values correctly? >> >> I've been referencing this web page for trying to get my code to work >> >> >> >> >> >> >> https://incubator.apache.org/odftoolkit/simple/document/cookbook/Style%20Handling.html#Advanced%20font%20handling >> >> >> >> Thanks, >> >> >> >> Andrew >> >> >> >> P.S. This list is very quiet but I'm hoping someone is reading it from >> >> time to time. >> >> >> >> >> >
