Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write an excel table starting from the last value?
    primarykey
    data
    text
    <p>I am using JXL api. I want to fill an excel table that already have content, like:</p> <pre><code>123 321 12324 123 321 231 123 321 343 123 321 454 123 321 565 </code></pre> <p>I am trying to write the next value after the fifth line, but I dont know how to do it. I only know how to create and write an excel table if it is empty. And I know how to read it. I was thinking that first I have to read it, and my array which would contain the values of the table would help me to pick the last value of the table then I would write the other values starting from there. I have these methods:</p> <p>To read:</p> <pre><code>arquivo = new File("C:\\Users\\maniceto\\Desktop\\arq.xls"); planilha = Workbook.getWorkbook(arquivo); Sheet[] abas = planilha.getSheets(); aba = planilha.getSheet(0); matriz = new String[aba.getRows()][aba.getColumns()]; Cell[] cel; for (int i = 0; i &lt; matriz.length; i++) { cel = aba.getRow(i); for (int j = 0; j &lt; matriz[0].length; j++) { matriz[i][j] = cel[j].getContents(); } } System.out.println("Lines " + matriz.length); System.out.println("Columns " + matriz[0].length); System.out.println(""); for (int i = 0; i &lt; matriz.length; i++) { for (int j = 0; j &lt; matriz[0].length; j++) { System.out.print(matriz[i][j] + "\t"); } System.out.println(""); } </code></pre> <p>To write an empty excel table:</p> <pre><code>WritableWorkbook workbookVazio = Workbook.createWorkbook(file); WritableSheet sheet1 = workbookVazio.createSheet("First Sheet", 0); TableModel model = table.getModel(); for (int i = 0; i &lt; model.getColumnCount(); i++) { Label column = new Label(i, 0, model.getColumnName(i)); sheet1.addCell(column); } int j = 0; for (int i = 0; i &lt; model.getRowCount(); i++) { for (j = 0; j &lt; model.getColumnCount(); j++) { Label row = new Label(j, i + 1, model.getValueAt(i, j).toString()); sheet1.addCell(row); } } workbookVazio.write(); workbookVazio.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload