Edit Existing Excel via Java

Hi every one,
I am using core java now.
I need to compare to two excel files between common elements.
I did it in core java.
But now i am need to modify existing excel file(width , height and color only) when two excel files between common fields only.
Please help me asap ,
Any suggestion appreciate
regards,
sundar

Hello Sundar,
I think you have not gone through the link properly. It properly mention that using HSSF you can work on Excel sheet.
It solves your problem for modification:
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
HSSF and XSSF provides ways to read spreadsheets create, modify, read and write XLS spreadsheets. They provide:
    * low level structures for those with special needs
    * an eventmodel api for efficient read-only access
    * a full usermodel api for creating, reading and modifying XLS filesThis will be more concern to you:
If you're modifying spreadsheet data then use the usermodel api. You can also generate spreadsheets this way.If you want to see some examples, please google it, you will get many.
Regards,
Ravi-India

Similar Messages

  • Please Help...!!  Is this to possible add data to write excel via java script

    Team:
    Is this possible to write data to Excel using javascript.
    I have created ScriptUI Dialog window. but i can't able to store datas in Excel.
    I can add data column wise in excel( using writeln comment) but I can't able add data to Row wise.
    Please anyone help me to solve this problem...
    Thanks in Advance.
    -yajiv
    Source Window :
    and the outputs wants......
    save the excel name to the Batch ID..

    Hi Everyone!
    I can add data column wise in excel( using writeln comment) but I can't able add data to Row wise.
    Please anyone help me to solve this problem...
    Thanks in Advance...
    -yajiv....
    Code :
    var myDoc = app.activeDocument;
    var myAllLinks = myDoc.allGraphics;
    var myLink=new Array()
    var mySeen = Object;
        var myLogFile = new File("~/Desktop/Link Files.xls");
        myLogFile.open("w", undefined, undefined)
        myLogFile.writeln("Link Name");
          for ( i = 1; i < myAllLinks.length; i++ )
                var myLinkName = myAllLinks[i].itemLink.name;
                var l=myLinkName.length;
               var T=myLinkName.substring(l-4);
                if (T==".tif"){
                    myLogFile.writeln(myAllLinks[i].itemLink.name);

  • I currently am using Office 2004 student version on a powerpc running version 10.4.11. I have a newer computer w/ intel duo core running 10.7. I want to install Office 2008 business version and share and edit existing excel files. Will I have a conflict ?

    I am interested in buying Office 2008 and transferring Excel data from my Powerpc iMac which runs 10.4.11 and Office 2004 student version. I wish to constantly use and update the Excel files. Will I have a conflict?

    You shouldn't have a problem, I am running 2008 and all my data from 2004 carried over.  Office 2011 will also run on 10.7.

  • When I create an event on my mac ical then sync to my iphone, I cannot later edit the event via my iphone. I used to be able to do this before. Can someone please tell me why this option does not exist anymore? I have iphone 3Gs and can't use iCloud.

    When I create an event on my mac ical then sync to my iphone, I cannot later edit the event via my iphone. I used to be able to do this before. Can someone please tell me why this option does not exist anymore? I have iphone 3Gs and can't use iCloud due to older running system on my macbook pro.

    Lyndsay237 wrote:
    This device does not have a sim card in it. Could this be the reason or am I missing something when I am trying to update.
    Yes. You can't update or restore any GSM iPhone without a valid sim card installed in the phone. The sim card need not be activated, but it must be valid & present. If you want to update, you need to get a sim card.

  • Open & Edit an Excel File

    I am using 'Write to XL' Example VI with Labview 7.0 .
    I would like to be able the data on the front panel to an already existing Excel spreadsheet, without deleting the old data in the original spreadsheet. 
    I have the opening an existing spreadsheet handled, but I cannot seem to write without losing the old data first.
    I have attached my edited VI & the example VI [almost identical, but nonetheless...]
    Thanks!
    Attachments:
    Write Table To XL.vi ‏86 KB
    Write Table To XL2.vi ‏93 KB

    Scott P wrote:
    Hello,
          There are some words missing for me to understand exactly what you want to do.  You state "I would like to be able the data...."  What is it you want to do with the data.  I'm guessing that you want to be able to ADD the data to an exising Excel file without disturbing the old data.  Is that true.  I couldn't tell from your vi's because I couldn't properly open them.  I have LabView 7.1 and I may not have all of the sub-vi's you do.  It would help if you would save your vi's into an library file with the supporting vi's included.  Then I can easily open the vi and look at it.  Try "Save with Options" and tick "Application Distribution".  It should default to a library file (llb).  Then post that. 
    Thanks, Scott
    I
    would like to be able to ADD data on the front panel to an already
    existing Excel spreadsheet, without deleting the old data in the
    original spreadsheet. 
    Sorry about that, I couldn't even make sense of it when I read it, lol. 
    I will resave the Vi in the morning with the subvis attached. 
    Thanks!

  • How to Edit Existing  PDF

    Hi... i am try to edit existing pdf in itext any one can help me this sending code.......

    Using Itext i want to remove some content in the PDF
    This is my code i want to Edit or Remove some text in the Pdf
    package view;
    //import com.itextpdf.text.BaseColor;
    //import com.itextpdf.text.DocumentException;
    //import com.itextpdf.text.pdf.PdfContentByte;
    //import com.itextpdf.text.pdf.PdfCopyFields;
    //import com.itextpdf.text.pdf.PdfStamper;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfCopy;
    import com.lowagie.text.pdf.PdfCopyFields;
    import com.lowagie.text.pdf.PdfDictionary;
    import com.lowagie.text.pdf.PdfImportedPage;
    import com.lowagie.text.pdf.PdfName;
    import com.lowagie.text.pdf.PdfNumber;
    import com.lowagie.text.pdf.PdfReader;
    import com.lowagie.text.pdf.PdfStamper;
    import java.awt.Color;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    public class SplitingFlat {
        public static void main(String[] args) {
            String fileName =
                "D://OMR//OMRpdf//FlatFlies//EligibilityLists_Flat.pdf";
            splitPDFFile(fileName);
            rotateFlatPDF();
            markPdf();
            mergeFlatPdf();
        public static List splitPDFFile(String fileName) {
            List list = new ArrayList();
            int startPageNo[] =
            { 1, 29, 47, 67, 85, 133, 179, 197, 225, 243, 277, 295, 319, 337, 365,
              393, 419, 439, 471, 491, 513 };
            int endPageNo[] =
            { 28, 46, 66, 84, 132, 178, 196, 224, 242, 276, 294, 318, 336, 364,
              392, 418, 438, 470, 490, 512, 532 };
            try { /**
                     * Read the input PDF file
                PdfReader reader = new PdfReader(fileName);
                int totalPages = reader.getNumberOfPages();
                int split = 0;
                for (int i = 0; i < endPageNo.length; i++) {
                    for (int pageNum = 1; pageNum <= totalPages;
                         pageNum += endPageNo[i]) {
                        if (pageNum == 1) {
                            pageNum = startPageNo[i];
                        split++;
                        String outFile =
                            "D://OMR//OMRpdf//flat//split//Flat-split-" + split +
                            ".pdf";
                        Document document =
                            new Document(reader.getPageSizeWithRotation(1));
                        PdfCopy writer =
                            new PdfCopy(document, new FileOutputStream(outFile));
                        document.open();
                        int tempPageCount = 0;
                        int number = endPageNo[i] - pageNum;
                        for (int offset = 0;
                             offset < number && (pageNum + offset) <= totalPages;
                             offset++) {
                            PdfImportedPage page =
                                writer.getImportedPage(reader, pageNum + offset);
                            writer.addPage(page);
                            tempPageCount++;
                        document.close();
                        writer.close();
                        list.add(outFile);
                        break;
            } catch (Exception e) {
                e.printStackTrace();
            return list;
        private static void rotateFlatPDF() {
            String pdfFolderPath = "D:\\OMR\\OMRpdf\\flat\\split\\";
            int split = 1;
            File pdfFolder = new File(pdfFolderPath);
            if (pdfFolder != null && pdfFolder.isDirectory()) {
                String[] pdfFileNames = pdfFolder.list();
                if (pdfFileNames != null && pdfFileNames.length > 0) {
                    int documentNumber = 0;
                    for (String pdfFileName : pdfFileNames) {
                        File pdfFile =
                            new File(pdfFolderPath + File.separator + pdfFileName);
                        if (pdfFile.isFile()) {
                            documentNumber++;
                            PdfReader pdfReader;
                            String opFile =
                                "D:\\OMR\\OMRpdf\\flat\\rotate\\" + "DocumentSplitRotate-" +
                                split + ".pdf";
                            try {
                                pdfReader =
                                        new PdfReader(pdfFolderPath + File.separator +
                                                      pdfFileName);
                                int n = pdfReader.getNumberOfPages();
                                int rot;
                                PdfDictionary pageDict;
                                for (int i = 1; i <= n; i++) {
                                    rot = pdfReader.getPageRotation(i);
                                    pageDict = pdfReader.getPageN(i);
                                    pageDict.put(PdfName.ROTATE,
                                                 new PdfNumber(rot - 90));
                                PdfStamper stamper =
                                    new PdfStamper(pdfReader, new FileOutputStream(opFile));
                                stamper.close();
                                pdfReader.close();
                                split++;
                            } catch (IOException e) {
                            } catch (DocumentException e) {
        public static void markPdf() {
            try {
                //Flat
                String pdfFolderPath = "D:\\OMR\\OMRpdf\\flat\\rotate";
                File pdfFolder = new File(pdfFolderPath);
                if (pdfFolder != null && pdfFolder.isDirectory()) {
                    String[] pdfFileNames = pdfFolder.list();
                    if (pdfFileNames != null && pdfFileNames.length > 0) {
                        int documentNumber = 0;
                        for (String pdfFileName : pdfFileNames) {
                            File pdfFile =
                                new File(pdfFolderPath + File.separator +
                                         pdfFileName);
                            if (pdfFile.isFile()) {
                                documentNumber++;
                                PdfReader pdfReader =
                                    new PdfReader(pdfFolderPath + File.separator +
                                                  pdfFileName);
                                int pageCount = pdfReader.getNumberOfPages();
                                    String outputFileName =
        "D:\\OMR\\OMRpdf\\flat\\mark\\" +File.separator +pdfFileName.substring(0, pdfFileName.lastIndexOf(".pdf")) +
                                "_OMR_Marked.pdf";
                                FileOutputStream fileOutputStream =
                                new FileOutputStream(outputFileName);
                                PdfStamper pdfStamper =
                                new PdfStamper(pdfReader,
                                               fileOutputStream);
                                for (int i = 1; i <= pageCount; i++) {
                                PdfContentByte cb =
                                    pdfStamper.getOverContent(i);
                                cb.beginText();
                                cb.setColorStroke(Color.RED);
                                if (OMRMarkingUtilityFlatfold.isFlatZone1MarkingEnabled(documentNumber,
                                                                                i))
                                    OMRMarkingUtilityFlatfold.drawFlatOMRMark(cb,
                                                                      1, i,
                                                                      pageCount);
                                if (OMRMarkingUtilityFlatfold.isFlatZone2MarkingEnabled(documentNumber,
                                                                                i)) {
                                    PdfContentByte cb2 =
                                        pdfStamper.getOverContent(pageCount);
                                    OMRMarkingUtilityFlatfold.drawFlatOMRMark(cb2,
                                                                      2, i,
                                                                      pageCount);
                                if (OMRMarkingUtilityFlatfold.isFlatZone3MarkingEnabled(documentNumber,
                                                                                i)) {
                                    PdfContentByte cb3 =
                                        pdfStamper.getOverContent(1);
                                    OMRMarkingUtilityFlatfold.drawFlatOMRMark(cb3,
                                                                      3, i,
                                                                      pageCount);
                                if (OMRMarkingUtilityFlatfold.isFlatZone4MarkingEnabled(documentNumber,
                                                                                i))
                                    cb.endText();
                                pdfStamper.close();
                                fileOutputStream.close();
            catch (IOException ioe) {
                ioe.printStackTrace();
            } catch (DocumentException de) {
                de.printStackTrace();
        private static void mergeFlatPdf() {
            try {
                PdfCopyFields copy =
                    new PdfCopyFields(new FileOutputStream("D:\\OMR\\OMRpdf\\flat\\merge\\output1.pdf"));
                String pdfFolderPath = "D:\\OMR\\OMRpdf\\flat\\mark\\";
                File pdfFolder = new File(pdfFolderPath);
                if (pdfFolder != null && pdfFolder.isDirectory()) {
                    String[] pdfFileNames = pdfFolder.list();
                    if (pdfFileNames != null && pdfFileNames.length > 0) {
                        for (String pdfFileName : pdfFileNames) {
                            copy.addDocument(new PdfReader(pdfFolderPath +
                                                           pdfFileName));
                copy.close();
            } catch (IOException e) {
            } catch (DocumentException e) {
    package view;
    import com.lowagie.text.pdf.PdfContentByte;
    import org.apache.log4j.Logger;
    public class OMRMarkingUtilityFlatfold {
        private static final Logger logger =
            Logger.getLogger(OMRMarkingUtilityFlatfold.class);
        //public static final int Flat_Zone_X_Position     = 14;    // 0.1875 inches
        public static final int Flat_OMR_Mark_Thickness = 1; // 0.01   inches
        public static final int Flat_OMR_Mark_Length = 29; // 0.3    inches
        public OMRMarkingUtilityFlatfold() {
            super();
        public static boolean isFlatZone1MarkingEnabled(int documentNumber,
                                                        int pageNumber) {
            boolean flatZone1 = true;
            //        if (pageNumber % 2 != 0)
            //            trifoldZone4 = true;
            return flatZone1;
        public static boolean isFlatZone2MarkingEnabled(int documentNumber,
                                                        int pageNumber) {
            boolean flatZone2 = true;
            //        if (pageNumber % 2 != 0)
            //            trifoldZone4 = true;
            return flatZone2;
        public static boolean isFlatZone3MarkingEnabled(int documentNumber,
                                                        int pageNumber) {
            boolean flatZone3 = true;
            //        if (pageNumber % 2 != 0)
            //            trifoldZone4 = true;
            return flatZone3;
        public static boolean isFlatZone4MarkingEnabled(int documentNumber,
                                                        int pageNumber) {
            boolean flatZone4 = true;
            //        if (pageNumber % 2 != 0)
            //            trifoldZone4 = true;
            return flatZone4;
        public static int getFlat_Zone_X_Position() {
            return getFlat_Zone_X_Position();
        public static int getFlat_Zone3YPosition() {
            return getFlat_Zone3YPosition();
        public static int getFlat_Zone4YPosition() {
            return getFlat_Zone4YPosition();
        public static void drawFlatOMRMark(PdfContentByte cb, int zone,
                                           int pageNumber, int pageCount) {
            float x;
            float y;
            System.out.println(pageNumber);
            if (pageNumber == 1) {
                x = 14;
            } else {
                x = 7;
            switch (zone) {
            case 1:
                if (pageNumber == 1)
                    y = 689;
                else {
                    y = 688;
                break;
            case 2:
                y = 679;
                break;
            case 3:
                x = 14;
                y = 670;
                break;
            case 4:
                if (pageNumber == 1)
                    y = 661;
                else {
                    y = 660;
                break;
            default:
                y = 0;
                break;
            cb.moveTo(x, y);
            cb.lineTo(x + Flat_OMR_Mark_Length, y);
            cb.stroke();

  • Oracle Database Express Edition 2 Day Plus Java Developer Guide??

    I posted in the JDeveloper forum, as well as sending email via your feedback link found on the tutorial but I am a little disappointed by this:
    The Oracle® Database Express Edition 2 Day Plus Java Developer Guide has some errors in it.
    in Windows, I simply chose, start
    -> programs -> Oracle Database Express Edition -> Go To Database Home Page -> click documentation from the link -> and run the Oracle® Database Express Edition 2 Day Plus Java Developer Guide tutorial.
    the problem is there are mistake(s) in the tutorial, for example: section 4-19 is this:
    "The complete code for the method should now be as follows:
    public boolean authenticateUser(String userid, String password,
    HttpSession session) throws SQLException { "
    it needs to be this:
    public boolean authenticateUser(String jdbcURL, String userid, String password,
    HttpSession session) throws SQLException {
    Also:
    there is no mention that :
    the port and SID must also be passed in the
    ds.setURL(jdbcUrl) found in the authenticateUser() method, or an exception is thrown. This differs from value of the jdbcUrl string found in the getDBConnection() , which makes it hard to figure out
    The tutorial is great even if it doesn't work out of the box, but I am disappointed that errata or completed code for this project is not available, especially when you explicitely point to it via the steps mentioned above.
    Thanks,
    Patrick

    The tutorial seems to be using the old JDeveloper 10.1.2.
    If you are aiming to learn JDeveloper then just use the tutorials linked from the JDeveloper home page.
    http://www.oracle.com/technology/obe/obe1013jdev/index.htm

  • ODI reading Excel via ODBC on Linux

    I've got ODI loading data from Excel via ODBC with everything running on Windows, and it runs fine!
    But will this work when I run ODI on a Linux platform? Will I have to buy some kind of ODBC driver for Excel under Linux? Has anyone done this before?
    Any help gratefully received!
    Thanks
    A

    There exists a native JDBC driver for excel, it is a sourcefourge project. This allows you to read excel data irrespective of platform through JDBC rather than having to use the JDBC/ODBC bridge.

  • Aspose.Excel for Java Plan before End of June, 2005

    Now we are working on Aspose.Excel for Java. It�s a Java equivalent of Aspose.Excel. The first version will be released at the end of June which will include the following feature list:
    1. Edit cells� data
    2. Style settings
    3. Manipulate worksheets
    4. Protect/Unprotect a worksheet
    5. Access rows and columns
    6. Excel file options settings
    7. Hyperlinks
    8. Freeze panes
    9. Page Setup
    10. Pagebreaks
    11. Data formats
    12. Formula
    13. Import/Export JDBC data abstractions
    14. Keep pictures, charts,drawing objects in template file
    15. Keep VBA/Macro in template file
    16. Keep Pivot Table/Chart in template file

    Sorry but you have the wrong forum.
    ka

  • Custom reports / edit existing reports

    I would like to edit some existing reports in Service Desk. Many report do what I'm looking for except for one thing. All 'closed reports' report the closed/resolved step in the workflow. We have a validation step on which I would like to report. How can I edit existing reports to match this? We are currently running 6.2 but can upgrade to 6.5 if needed.
    With the report builder in 6.5 is it possible to edit these reports without having to make them from scratch?

    Do you see any error when you run the ETL, i.e. the Java ETL embedded with the app server? 

  • Extract image and Features from the Catalog via JAVA API

    Hello,
    I would like to Extract image from the Catalog via JAVA API, Can anybody help on that? I also tried to extract the Features field form the Catalog but results in the error "Features field not found" Any ideas what could have wrong?
    Many thanks,
    Dharmi

    Hello,
    Can anybody tell me where i can find the latest JAVAAPI reference guide? I found the one for MDM 5.5 SP 1 but that also refers to the last parameter of the CatalogCache.Init as int and not string.
    I looked up in service.sap.com/instguides -> SAP Netweaver -> Release 4 -> Installation and there only following 3 files are there for MDM 5.5 SP2
    MDM 5.5 SP02 - Configuration Guide  SAP MDM
    MDM 5.5 SP02 - Installation Guide   SAP MDM
    MDM 5.5 SP02 – ERP-MDM Field Mapping and Check Tables
    Regards,
    Dharmi
    Message was edited by: Dharmi Tanna
    Message was edited by: Dharmi Tanna

  • Writting to an specific spreadsheet of an existing excel file.

    I need to write a labview 2-D array of real numbers to an specifc spreadsheet of an existing excel file (which has many sheets and is located in my hard disk).  
    Some years ago a member forum wrote a nice and small code for writting to excel.  The code is http://forums.ni.com/ni/attachments/ni/6170/107/1/Excel.vi and was posted here http://forums.ni.com/ni/board/message?board.id=6170&thread.id=105
    I found that it would be useful after some modifications. How to modify it in order to get what I need?  (Obs.: My LabVIEW version is 8.0)
    Message Edited by fgarcia on 02-06-2010 08:39 AM
    Message Edited by fgarcia on 02-06-2010 08:40 AM

    There is a function to do that in the Excel specific VIs palette of the Report Generation Toolkit. Of course you need to have the toolkit installed. You can also use the invoke and property nodes on the Excel object but you have to find out what are the appropriate methods to use and propriety to set (you should find the information in an Excel programming manual. in VBA it is something like worksheet("Sheet2").Select). You can use the Workbook OPEN method to open the Excel workbook saved on you hard disk (connect your file path to the Filename input of the invoke node).
    Ben

  • Writing to a cell in an existing Excel file without prompt of overwritin​g

    I am trying to learn communicating with Excel spreadsheet via ActiveX. I started with the Labview example "Write Table to XL", however, this example creates new file which is not my case of overwriting an existing Excel spreadsheet. So, I made my changes to the VI to overwrite an existing file with my new value. Unfortunately, there is always prompt of overwriting the file, and even though I press "yes", the file keeps unchanged.
    The help I need is to kindly :
    1- check my attached VI for any mistakes
    2- make the VI overwriting the file without any prompts
    Thanks in advance
    Solved!
    Go to Solution.
    Attachments:
    Write_Value_to_Cell_ActiveX.vi ‏17 KB

    I really appreciate your help, but I already changed the configuration to open a file path taking another ActiveX example as a reference. Here is my subVI's I used, but they are merged in LLB. I am sorry for my ignorance of how to extract all the subVI's from this file.
    Attachments:
    ExcelExamples.llb ‏62 KB

  • To write contents in an existing excel file

    Hi All,
    I want to know Using JXL API,how to write the contents in an existing excel file.

    http://www.andykhan.com/jexcelapi/tutorial.html
    PS. JXL is not Java Excel API.

  • Integrating Excel with Java

    Hi,
    How can Excel be integrated with Java such that if a user is working on an Excel , my Java application should be able to capture all the events from Excel Sheet.
    I have looked into POI, but it seems to me , it can read and wriite to Excel from Java, but i would like that if a user is making changes to a spredsheet then my Java Application should be notified about those changes
    In short, i would like to expose front end of a web application in Execl!
    Is there any open source package that can help in doing the integration
    Kindly share your views/ suggestions

    jschell wrote:
    If you just want most of what is occuring in Excel only then there are probably events in the Excel API (OLE >probably) that allow you to modify and react to changes. In my experience figuring out how to do that is very >difficult even for small bits of functionality.Can u please explain a little more on this.
    Can i use JNI to listen to COM server, probaly if i create some proxies for Excel that use JNI to listen to COM Server.
    I found a link on the internet http://www.ibm.com/developerworks/java/library/j-bridge/
    This Java bridge can integrate COM objects into their applications. But i am not sure if i can capture the live stuff from an Excel file when somebody is editing it.
    Also i would like to know, what should be the best stratergy when i would like to expose the Front end of an application in Excel , since the application involves a lot of numbers and users are more comfortable with Excel interface, and the rest of the application you want in Java.
    Kindly share your views on this!

Maybe you are looking for