title: How to insert a row between two rows in an existing excel with HSSF (Apache POI)
body: <p>Somehow I manage to create new rows between two rows in an existing excel file. The problem is, some of the formatting were not include along the shifting of the rows. </p>
  
  <p>One of this, is the row that are hide are not relatively go along during the shift. What I mean is(ex.), rows from 20 to 30 is hidden, but when a create new rows the formating still there. The hidden rows must also move during the insertion/creation of new rows, it should be 21 to 31. </p>
  
  <p>Another thing is, the other object in the sheet that are not in the cell. Like the text box are not move along after the new row is created. Its like the position of these object are fixed. But I want it to move, the same thing as I insert a new row or paste row in excel. If there is a function of inserting a new row, please let me know.</p>
  
  <p>This what I have right now, just a snippet from my code.</p>
  
  <pre><code>HSSFWorkbook wb = new HSSFWorkbook(template); //template is the source of file
  HSSFSheet sheet = wb.getSheet("SAMPLE");
  HSSFRow newRow;
  HSSFCell cellData;
  
  int createNewRowAt = 9; //Add the new row between row 9 and 10
  
  sheet.shiftRows(createNewRowAt, sheet.getLastRowNum(), 1, true, false);
  newRow = sheet.createRow(createNewRowAt);
  newRow = sheet.getRow(createNewRowAt);
  </code></pre>
  
  <p>If copy and paste of rows is possible that would be big help. But I already ask it here and can't find a solution. So I decided to create a row as an interim solution. I'm done with it but having a problem like this. </p>
  
  <p>Any help will be much appreciated. Thanks!</p>