Results 1 to 5 of 5
- 07-06-2010, 08:51 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 2
- Rep Power
- 0
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
- 07-06-2010, 08:55 AM #2
Member
- Join Date
- Jul 2010
- Posts
- 2
- Rep Power
- 0
And i m using Jexcel API's
- 07-07-2010, 04:32 PM #3
Member
- Join Date
- Feb 2009
- Posts
- 15
- Rep Power
- 0
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.
- 07-07-2010, 07:13 PM #4
Member
- Join Date
- Jul 2009
- Posts
- 12
- Rep Power
- 0
- 07-07-2010, 07:33 PM #5
Member
- Join Date
- Feb 2009
- Posts
- 15
- Rep Power
- 0
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.
Hope this helps, more spec questions would be nice too. Thanks
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)
{
}
}
Similar Threads
-
why i can't insert data to database
By khaa_khay in forum Web FrameworksReplies: 0Last Post: 05-26-2010, 05:37 AM -
Is it possible to insert recorded audio data into an existing file?
By evan_earnest in forum Threads and SynchronizationReplies: 1Last Post: 01-31-2010, 03:40 AM -
Is it possible to insert recorded audio data into an existing file?
By evan_earnest in forum New To JavaReplies: 4Last Post: 01-21-2010, 09:31 AM -
How to insert large data into database using one insert query
By sandeepsai39 in forum New To JavaReplies: 3Last Post: 02-28-2009, 09:17 AM -
storing exel data to access database
By sijokunnappilly in forum Advanced JavaReplies: 1Last Post: 10-30-2008, 07:59 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks