How do I save a xls document in Java

Hi!
How do I save a xls Document from java?
I mean, I want to specify which xls document to save and then save it.
Any useful code would be of great help!

This is the code!
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Locale;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.write.Label;
import jxl.write.WritableCell;
import jxl.write.WritableCellFormat;
import jxl.write.WritableImage;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Number;
import jxl.write.*;
import java.io.IOException;
import java.io.OutputStream;
  public class writeXls
        public String templateName;
        public String outputName;
      public writeXls (String t, String o)
         templateName = "c://"+t;
         outputName = "c://"+o;
      public void writeYearVolume(String []yearvolymeArray)
          WritableWorkbook workbook = null;
          try
              // Setup workbook
              WorkbookSettings ws = new WorkbookSettings();
              ws.setLocale(Locale.UK);
              ws.setEncoding("Windows-31J");
              // Load workbook
              Workbook template = Workbook.getWorkbook(new FileInputStream(templateName));
              // Create new workbook
              workbook = Workbook.createWorkbook(new FileOutputStream(outputName), template, ws);
              // Create new sheet
              WritableSheet sheet = workbook.getSheet(1);
              // Create new label
              Number amc1000= new Number(4, 1, Integer.parseInt(yearvolymeArray[0]));
              Number amc800 = new Number(4, 2, Integer.parseInt(yearvolymeArray[1]));
              sheet.addCell(amc1000);
              sheet.addCell(amc800);
              // Write wookbook
              workbook.write();
              workbook.close();
            catch (IOException e)
              e.printStackTrace();
            catch (WriteException e)
              e.printStackTrace();
            catch(Exception e)
                e.printStackTrace();
  }The xls file is modified but not saved, how do I save the file?
Some of the cells in the xls file contains formulas, because of that, the cells containing formulas dosen't update its value.
if I however save the file manually then the cells are updated. I want to save the xls file automatically from Java.
Any ideas on how to do that?

Similar Messages

  • HT3705 How do I save a Pages document to jpeg so that I can share on social media?

    I have created a brochure and would like to post it on Facebook. How do I save a Pages document to jpeg so that I can share on social media and email? Do I have to save it as a jpeg or what other format can I save it in?

    Ashe,
    In Pages, Print to "PDF > Open PDF in Preview". From Preview, File > Export to the format or your choosing, one page at a time. For text, PNG would be better than JPG.
    Jerry

  • TS1702 I wish to save a multi page document sent by e mail as PDF in Pages - it only files the first page? How do I save the entire document ?

    I have Pages on my iPad, which is brilliant....but when I want to save a multi page file sent to me by e mail, pages only saves the first page. How do I save the entire document?

    What type of document is the file? (ie. what is the file extension for tie file?)
    Regards,
    Barry

  • How do i save a PDF document sent to me via email to Pages on my IPad

    Hey All,  I have a document that i want on my IPad.  How do i save a PDF document sent to me via email to Pages on my IPad?

    You can't. You can export Pages files as PDF documents but you cannot save a PDF into Pages. It does not support that feature.
    There are tons of PDF apps in the App Store aside from iBooks. Adobe Reader makes a pretty decent PDF app that will store, annotate, rename, highlight, use form fields, sign pdf's, and organize in folders. It is free as well. There are other apps, you just have to Serach for them.

  • How do I save a pdf document to my desktop?

    How do I save a pdf document to my desktop?

    You can use the Save As feature to save a copy to a different location.
    1. Open a PDF document in Adobe Reader Touch.
    2. Bring up the toolbars by swiping up from the bottom edge (Touch) or right-click with a mouse.
    3. Tap/click the Save As button in the bottom toolbar.
    (Click the image above to enlarge)
    For Windows 8/RT
    4a. In the File Browser, tap/click the down arrow button in the top left corner.
    5a. Select Desktop from the drop-down menu.
    6a. Tap/click the Save button.
    (Click the image above to enlarge)
    For Windows 8.1/RT 8.1
    4b. In the File Browser, tap/click the down arrow button in the top left corner.
    5b. Select This PC from the drop-down menu.
    (Click the image above to enlarge)
    6b. Tap/click the Desktop button.
    7b. Tap/click the Save button.
    (Click the image above to enlarge)
    By default,  " - Copy" (in your UI language) will be appended to the original file name.  You can change the file name to something else, if you'd like.

  • How do i save a pdf document from an e-mail?

    How do I save a PDF document to the Books App?

    Please don't post the same question multiple times!  Instead answer the questions in your original topic.

  • How do I save a scanned document as a PDF file?

    How can I save a scanned document as a PDF file.  I'm using a Photosmart C6280.
    This question was solved.
    View Solution.

    If you still have the document re-scan it using the Solution Center saving it as a pdf file.
    Please mark the post that solves your issue as "Accept as Solution".
    If my answer was helpful click the “Thumbs Up" on the left to say “Thanks”!
    I am not a HP employee.

  • How do I save an older document to pages '09 so I can open it in the versions of pages?

    How do I save an older document to pages '09 so I can open it in the versions of pages?

    Best is to Export to Word .doc files, just about all of the many versions of Pages can open those.
    Peter

  • Using an iPad wi-fi 3G. How do I save received email documents in the my device? Really hate having to go through my emails to find a document. And where do I save it?

    Using an iPad wi-fi 3G. How do I save received email documents in the my device? Really hate having to go through my emails to find a document. And where do I save it?

    triplembm wrote:
    I downloaded a PDF from an email and have been trying to save the file in my document file.  When using Snow Leopard I used to hit Command S and it would ask me where I wanted to save the document.  i just got an iMac with Lion and when I hit Command S I get nothing.
    Welcome to Lion's new feature: Versions
    How do I save a document using Lion? 
    To save a NEW copy in Preview:
         File->Export
    You said that you d/l'd a PDF in Mail, so why not just click the "Save" button in Mail?
    (Make sure that you click the "Details" button in Mail)
    In Mail:
    BTW, I'm very happy with Lion.  (In regard to all the negative Lion posts, ask yourself if you're more likely post a comment here telling us how happy you are with features of Lion, or to complain about something that's changed).

  • How do I save an old document in Pages 09 first?

    how do I save an old document in Pages 09 first?

    If you are dealing with a Pages '08 document and find that Pages v5 no longer supports it, here are your options for reading that content in Pages v5. Pick the best one for you:
    On a machine with Pages '08, export as an MS Word (.doc) document
    On a machine with Pages '09
    Open and save as a Pages '09 document
    Open and export as an MS Word (.doc) document
    Upload the Pages '08 document to the free zamzar conversion service, and receive a downloadable .docx via email link in about 4 minutes.
    Install the iWork '08 DVD on your current machine (including Yosemite) then immediately update with the following:
    Pages '08 v3.0.3
    Numbers '08 v1.0.3
    Keynote '08 v4.0.4
    Purchase and/or install the iWork '09 DVD
    Immediately apply the Apple iWork 9.3 updater.
    Some Pages functionality lost in Yosemite.
    New installations of iWork '08/'09 DVD, and updates should be followed by Disk Utility to verify/repair permissions.

  • HT2693 how can i save my pages document as a PDF file or jpeg now?

    Hi...
    How can i save my pages document as a PDF file or Jpeg file now that the share is NA.

    In Pages, go to File > Export > Word, so the document will be saved in .doc to be able to use it in Word

  • How do I save my Quark document as a pdf on my iMac?

    How do I save my Quark document as a pdf on my iMac?

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico my first language is Spanish. I do not speak English, however I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    If Quark doesn't offer its own method of doing so (check the manual), then try the built in method from OS X. Print the document. In the Print Dialog Box choose the PDF drop down menu at the bottom and then choose Save as PDF.

  • HT4641 How do I save a pages document into a format a pc can open?

    How do I save a pages document that a pc can open.  eg jpeg, rtf pdf etc?

    I assume you're using Pages on an iOS device since that is the forum you've posted in.
    Tap on the wrench/spanner at the upper right & choose Share & Print. From there you can choose to e-mail or save to iTunes & then choose a format such as PDF or Word.
    If you should be asking about Pages on a Mac, use File > Export & choose Word or PDF.

  • How can you save a pages document so it can be opened in Microsoft Word

    How can I save a pages document so it can be opened in a Windows (Word) program?

    Word can't read .pages documents. You have to export the Pages  document to a Word document. File > export or share > Word
    Download the Pages User Guide from your Pages Help menu to learn more about how Pages works.

  • How can I save my word documents in ICLOUD

    How can I save my word documents in ICLOUD

    You can't directly, as Microsoft don't include iCloud support in their apps.
    You'd have to open your Word file in Apple's Pages and save it to iCloud from there.

Maybe you are looking for

  • How to scan photos in jpg in windows 8 instead of pdf

    I had Windows Vista with photo gallery. Now i have Windows 8 with no photo gallery, but photos in a different format(they say photo gallery is not compatible with windows 8). I used to scan pictures and documents and they were saved in jpg. Now they

  • Importing from burned DVDs

    Hi, I'm about to buy a Canopus ADVC300 to import old VHS home movies into FCE, but I'd also like to import footage from some full length burned DVDs so that I can add effects, titling etc. (They're school plays, so no copyright protections, etc.) Can

  • Schedule Process Flow with sysdate input parameter

    Hi experts, I'm facing a problem trying to run a schedule in a job, The schedule is defined to run daily at 3am, and the job receive a sysdate parameter, when I start the schedule in the control center I put TO_CHAR (TRUNC (SYSDATE), 'DD / MM / YYYY'

  • ECC System Refresh  - impacts IDOC connections to PI

    All, Whenever we refresh ECC QA system with prod, we have to do all the ale/IDOC settings all over again in ECC QA to connect to QA PI. Can you please list the tables that are used for We20, We21, BD64, SM59 so that BASIS can take a backup of these t

  • EBS Extension For Endeca Version 4

    HI , I had installed the EBS Extension for Endeca by following the procedure as per the Document : Installing Oracle E-Business Suite Extensions for Oracle Endeca, Release 12.1.3.4 (Doc ID 1562372.1) The Database installation step completes Successfu