Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: appending from shell script to excel sheet

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default appending from shell script to excel sheet

    Dear All,

    I am new to java.
    I have a requirement in a my project as I need to add the data from a shell script to a excel sheet every day in a new row.

    I found this we can do by using java.

    Help me in this regard..

    Thanks in advance.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,669
    Thanks
    25
    Thanked 327 Times in 304 Posts

    Default Re: appending from shell script to excel sheet

    I use SmartXLS. It is not free, but the demo is. There is supposed to be a time limit on the demo, but I found that if you download it on one machine, and copy and paste the library over to another machine, the demo never runs out. This works because it bases its time from the downloaded machine, which when you move it, can no longer update the library. The creators dont mind me doing this because they told me that if I dont want to upgrade, just redownload the library when it times out. The documentation is not great. I've been getting support from the creaters via email despite them knowing I dont have a licensed version. They even provided me with an updated demo library with some bugs fixed. And I've made some powerful programs with their demo library, so I can help you out with any issues you have.

    Like I said, the documentation isnt great, but feel free to message me regarding any confusion, I can help with just about any issue you may have.

    To do something simple like inserting data into an Excel Sheet with SmartXLS, this is what you would do:
    import com.smartxls.WorkBook;
     
    public class ExcelTesting
    {
        public static void main(String[] args)
        {
        	try{
        	//Create new WorkBook Object
    		WorkBook workBook = new WorkBook();
    		//Set workBook sheet to get edited at the moment
    		workBook.setSheet(0);
     
    		//Create Values to get Inserted into WorkBook
    		String wordValue = "Insert Word";
    		double numberValueD = 3.5;
    		int numberValueI = 5;
    		String formulaValue = "A2+A3";
     
    		//Write wordValue to cell A1
    		workBook.setText(0,0,wordValue);
    		//Write numberValueD to cell A2
    		workBook.setNumber(1,0,numberValueD);
    		//Write numberValueI to cell A3
    		workBook.setNumber(2,0,numberValueI);
    		//Write formulaValue to cell A4
    		workBook.setFormula(3,0,formulaValue);
     
    		//Alternatively, you can use the generic setEntry method to set values. You cannot use this method to set formulas.
    		//Write numberValueD with General Type into cell B1
    		workBook.setEntry(0,1,numberValueD+"");
     
    		//Create the new Excel file and insert data
    		workBook.write("WriteBook.xls");
    		//Or you can create a 2007 Excel file and insert the data:
    		//workBook.writeXLSX("WriteBook.xlsx");
     
        	}catch(Exception e){System.out.println(e); 	}
        }
    }

    Once you learn how to use the Library, it is EXTREMELY simple to use.

Similar Threads

  1. insert(embed) a file object (.txt file) in MS excel sheet using java.
    By jyoti.dce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 12th, 2010, 08:16 AM
  2. how to copy cells to a new sheet of excel with JexcelAPI??
    By 19world in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: June 15th, 2010, 03:49 AM
  3. Print Content on Pre Printed Sheet
    By kalees in forum Java Theory & Questions
    Replies: 0
    Last Post: February 24th, 2010, 02:26 AM
  4. Problem with a waitFor() executing a script
    By Baldurian in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 29th, 2010, 09:45 AM
  5. Hibbard Shell Sort
    By biglandphil in forum Algorithms & Recursion
    Replies: 3
    Last Post: November 12th, 2009, 09:14 PM