Results 1 to 5 of 5
  1. #1
    ak.arjun is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default Insert data in already exisisting exel file using jxl

    Hi all,

    I want to insert in a already excel sheet i have been able to find codes for creating new workbook and then writing data to it even reading is easy but i could not find the code to insert data in a existing excel.Please post your thoughts and solutions

    Thanks

  2. #2
    ak.arjun is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    And i m using Jexcel API's

  3. #3
    Join Date
    Feb 2009
    Posts
    15
    Rep Power
    0

    Default

    I just had this problem with a program that I just wrote. The easiest way i found is to have 2 excel files. You need 2 because you need one be read and then one so the program thinks its creating a new writable one, because you get non compatible errors if you do not. When the program opens get all the info from the regular workbook and populate it into a 2 dimensional array. Then have the program do its thing, and store new data to the array. After that have a save button or something, or however you want to export the workbook. Populate the writable workbook sheet with the array, then (here's the key) before you *.write and *.close set the output file to the readable regular excel file name you used to populate the array at the beginning. I hope that makes sense, the syntax is "yourWorkbook.setOutputFile(The string of the readable excel file name);". Hope that helps let me know if you have questions
    Last edited by thehighlander12; 07-07-2010 at 04:35 PM.

  4. #4
    Harpreet1111 is offline Member
    Join Date
    Jul 2009
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by thehighlander12 View Post
    I just had this problem with a program that I just wrote. The easiest way i found is to have 2 excel files. You need 2 because you need one be read and then one so the program thinks its creating a new writable one, because you get non compatible errors if you do not. When the program opens get all the info from the regular workbook and populate it into a 2 dimensional array. Then have the program do its thing, and store new data to the array. After that have a save button or something, or however you want to export the workbook. Populate the writable workbook sheet with the array, then (here's the key) before you *.write and *.close set the output file to the readable regular excel file name you used to populate the array at the beginning. I hope that makes sense, the syntax is "yourWorkbook.setOutputFile(The string of the readable excel file name);". Hope that helps let me know if you have questions
    I am also having the same problem.... I will be grateful to you if you can post some code to do this...

    Please do this...

    Regards
    Harpreet1111

  5. #5
    Join Date
    Feb 2009
    Posts
    15
    Rep Power
    0

    Default

    As you can see ImportExcel.book is my file name from the original imported excel file that way is always saves and reads the same one. This is also useful for data storage.


    import java.io.File;
    import java.util.Date;
    import java.util.Arrays;
    import jxl.*;
    import jxl.write.*;

    public class ExportExcel
    {

    private static WritableWorkbook exportWorkbook;
    private static WritableSheet exportSheet;

    public static void main()
    {
    try
    {
    exportWorkbook = Workbook.createWorkbook(new File("allInfo_2.xls"));
    exportSheet = exportWorkbook.createSheet("BusInfo", 0);

    }
    catch(java.io.IOException e)
    {

    }

    }

    public static void export()
    {
    Main.arrayCount();
    for(int i = 0; i < 24; i++)
    {
    for(int j = 1; j <= Main.arrayLength; j++)
    {
    try
    {
    exportSheet.addCell(new Label(i,j, Global.busInfo[j -1][i]));
    }
    catch(jxl.write.WriteException e)
    {

    }

    }
    }
    try
    {
    exportWorkbook.setOutputFile(ImportExcel.book);
    exportWorkbook.write();
    exportWorkbook.close();
    }
    catch(java.io.IOException e)
    {

    }
    catch(jxl.write.WriteException e)
    {

    }

    }
    Hope this helps, more spec questions would be nice too. Thanks

Similar Threads

  1. why i can't insert data to database
    By khaa_khay in forum Web Frameworks
    Replies: 0
    Last Post: 05-26-2010, 05:37 AM
  2. Is it possible to insert recorded audio data into an existing file?
    By evan_earnest in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-31-2010, 03:40 AM
  3. Replies: 4
    Last Post: 01-21-2010, 09:31 AM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. storing exel data to access database
    By sijokunnappilly in forum Advanced Java
    Replies: 1
    Last Post: 10-30-2008, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •