请输入您要查询的百科知识:

 

词条 JExcel
释义

  1. Some features

  2. Usage

     Example 

  3. See also

  4. References

  5. External links

{{Infobox software
| name = JExcel
| logo =
| screenshot =
| caption =
| developer = TeamDev
| latest release version = 1.7
| latest release date =
| latest preview version =
| latest preview date =
| operating system = Cross-platform
| programming language = Java
| genre = API to access Microsoft Excel format
| license = TeamDev[1]
| website = https://www.teamdev.com/jexcel
}}

JExcel is a library (API) to read, write, display, and modify Excel files with .xls or .xlsx formats. API can be embedded with Java Swing and AWT.

[2][3][4]

Some features

Some main features are as follows:

  • Automate Excel application, workbooks, spreadsheets, etc.
  • Embed workbooks in a Java Swing application as ordinary Swing component
  • Add event listeners to workbooks and spreadsheets
  • Add event handlers to handle the behavior of workbook and spreadsheet events
  • Add native peers to develop custom functionality.[2][3][4]

Usage

Primary usage is handling Excel files through its API.

Example

Sample code for reading/writing workbook attributes, setting password, and saving MS Excel 2003 format, might look like as follows:

import com.jniwrapper.win32.jexcel.Application;

import com.jniwrapper.win32.jexcel.FileFormat;

import com.jniwrapper.win32.jexcel.GenericWorkbook;

import com.jniwrapper.win32.jexcel.Workbook;

import java.io.File;

/**

 * This sample shows how to read/modify workbook attributes, how to save workbook in Excel 2003 format, * and how to reopen workbook. * * The sample works with MS Excel in non-embedded mode. */

public class WorkbookSample

{
    public static void main(String[] args) throws Exception    {        //Start MS Excel application, crate workbook and make it visible.        // Application starts invisible and without any workbooks        Application application = new Application();        Workbook workbook = application.createWorkbook("Custom title");
        File newFile = new File("Workbook.xls");        //Save workbook in Excel 2003, to save in Excel 2007 format use FileFormat.OPENXMLWORKBOOK        // format specificator and *.xlsx extension        workbook.saveAs(newFile, FileFormat.WORKBOOKNORMAL, true);
        File workbookCopy = new File("WorkbookCopy.xls");        workbook.saveCopyAs(workbookCopy);
        //Close workbook saving changes        workbook.close(true);
        //Reopening the workbook        workbook = application.openWorkbook(newFile, true, "xxx001");
        //Perform cleanup after yourself and close the MS Excel application forcing it to quit        application.close(true);    }
    /**     * Prints workbook attributes to console     * @param workbook - workbook to print information about     */    public static void printWorkbookAttributes(GenericWorkbook workbook)    {        String fileName = workbook.getFile().getAbsolutePath();        String name = workbook.getWorkbookName();        String title = workbook.getTitle();        String author = workbook.getAuthor();
        System.out.println("\[Workbook Information]");        System.out.println("File path: " + fileName);        System.out.println("Name: " + name);        System.out.println("Title: " + title);        System.out.println("Author: " + author);
        if (workbook.hasPassword())        {            System.out.println("The workbook is protected with a password");        }        else        {            System.out.println("The workbook is not protected with a password");        }        if (workbook.isReadOnly())        {            System.out.println("Read only mode");        }    }
    /**     * Modify workbook title, author and set password     * @param workbook - workbook to modify attributes     */    public static void modifyWorkbookAttributes(GenericWorkbook workbook)    {        workbook.setTitle("X-files");        workbook.setPassword("xxx001");        workbook.setAuthor("Agent Smith");    }

}

[5]

See also

  • Apache POI
  • Aspose API
  • JXL (API)
  • Open Packaging Conventions
  • Office Open XML software

References

1. ^{{Cite web|url =https://www.teamdev.com/jexcel-licence-agreement|title = JExcel Product Licence Agreement|date = |accessdate = 2 February 2016|website = TeamDev|publisher = TeamDev|last = |first = }}
2. ^{{Cite web|url = https://recalll.co/app/?q=excel%20-%20Java%20POI%20API:%20Convert%20from%20*.xlsx%20to%20*.xls|title = recall|date = |accessdate = 2 February 2016|website = Recall|publisher = |last = |first = }}
3. ^{{Cite web|url = http://www.geardownload.com/development/jexcel.html|title = JExcel 1.7|date = |accessdate = 2 February 2016|website = GearDownload|publisher = GearDownload|last = |first = }}
4. ^{{Cite web|url = http://www.directoryofshareware.com/preview/jexcel|title = JExcel 1.7|date = |accessdate = 2 February 2016|website = Directory of Shareware |publisher = Directory of Shareware|last = |first = }}
5. ^{{Cite web|url = https://sites.google.com/a/teamdev.com/jexcel-support/samples/basics/reading-and-writing-workbook-attributes-setting-password-saving-workbook-in-ms-excel-2003-format|title =Reading\\writing workbook attributes. Setting password. Saving workbook in MS Excel 2003 format |date = |accessdate = 2 February 2016|website = JExcel Support|publisher = JExcel Support|last = |first = }}

External links

  • {{citation | url = https://www.teamdev.com/jexcel| title = JExcel}} – the official JExcel page.

3 : Microsoft Office-related software|Java platform|Java (programming language) libraries

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/29 22:31:14