How to add a new row to an existing Excel file in java. (Using jxl) -
i have add new row existing excel file has data.
to make more clear , if excel has data upto 'n'th row , should add data 'n+1' th row.
i using jxl.jar , not apache poi.
import java.io.file; import jxl.workbook; import jxl.write.writableworkbook; import jxl.workbooksettings; import jxl.format.underlinestyle; import jxl.write.formula; import jxl.write.label; import jxl.write.number; import jxl.write.writablecell; import jxl.write.writablecellformat; import jxl.write.writablesheet; import jxl.write.writeexception; public class writexcel { static writableworkbook workbook; public static void main(string args[])throws exception { writableworkbook workbook = workbook.createworkbook(new file("c:/users/aj.xls")); writablesheet sheet = workbook.createsheet("first sheet", 0); label label = new label(0, 2, "ajeeth k"); sheet.addcell(label); workbook.write(); workbook.close(); //modify xls workbook workbook1 = workbook.getworkbook(new file("c:/users/aj.xls")); writableworkbook copy = workbook.createworkbook(new file("c:/users/527305/aj.xls"), workbook1); writablesheet sheet2 = copy.getsheet(0); writablecell cell = sheet2.getwritablecell(5, 2); sheet2.addcell(label); copy.write(); copy.close(); } }
Comments
Post a Comment