Convert Figma logo to code with AI

apache logopoi

Mirror of Apache POI

1,915
758
1,915
23

Top Related Projects

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator

11,465

ARCHIVED

33,890

Universal markup converter

31,958

快速、简洁、解决大文件内存溢出的java处理Excel工具

Quick Overview

Apache POI is a Java library for reading and writing Microsoft Office file formats, including Excel, Word, and PowerPoint. It provides a set of APIs to manipulate various file formats used by Microsoft Office programs, allowing developers to create, modify, and extract data from these files programmatically.

Pros

  • Comprehensive support for multiple Microsoft Office file formats
  • Active development and maintenance by the Apache Software Foundation
  • Extensive documentation and community support
  • Cross-platform compatibility

Cons

  • Large library size, which can increase application footprint
  • Steep learning curve for complex operations
  • Performance can be slower compared to native Office applications
  • Limited support for some advanced Office features

Code Examples

  1. Reading an Excel file:
FileInputStream file = new FileInputStream("workbook.xlsx");
Workbook workbook = new XSSFWorkbook(file);
Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
System.out.println(cell.getStringCellValue());
  1. Creating a new Word document:
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Hello, Apache POI!");
FileOutputStream out = new FileOutputStream("document.docx");
document.write(out);
out.close();
  1. Modifying a PowerPoint presentation:
FileInputStream file = new FileInputStream("presentation.pptx");
XMLSlideShow ppt = new XMLSlideShow(file);
XSLFSlide slide = ppt.createSlide();
XSLFTextBox textBox = slide.createTextBox();
textBox.setText("New slide created with Apache POI");
FileOutputStream out = new FileOutputStream("modified_presentation.pptx");
ppt.write(out);
out.close();

Getting Started

To use Apache POI in your Java project, add the following dependencies to your Maven pom.xml file:

<dependencies>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>5.2.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.2.3</version>
    </dependency>
</dependencies>

For Gradle, add these lines to your build.gradle file:

dependencies {
    implementation 'org.apache.poi:poi:5.2.3'
    implementation 'org.apache.poi:poi-ooxml:5.2.3'
}

After adding the dependencies, you can start using Apache POI in your Java code by importing the necessary classes and creating instances of the appropriate workbook or document types.

Competitor Comparisons

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator

Pros of ONNX Runtime

  • Focused on machine learning inference optimization
  • Cross-platform support for various hardware accelerators
  • Active development with frequent updates and releases

Cons of ONNX Runtime

  • Limited to machine learning tasks, not a general-purpose library
  • Steeper learning curve for non-ML developers
  • Requires understanding of ONNX format and model conversion

Code Comparison

ONNX Runtime (C++):

Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "test");
Ort::Session session(env, model_path, Ort::SessionOptions{nullptr});
auto output_tensors = session.Run(Ort::RunOptions{nullptr}, input_names, &input_tensor, 1, output_names, 1);

Apache POI (Java):

Workbook workbook = new XSSFWorkbook(new FileInputStream("example.xlsx"));
Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
String value = cell.getStringCellValue();

Summary

ONNX Runtime is specialized for machine learning inference optimization, offering cross-platform support and frequent updates. However, it has a narrower focus and steeper learning curve compared to Apache POI. POI is a more general-purpose library for working with Microsoft Office documents, making it easier to use for non-ML tasks but lacking the specialized ML capabilities of ONNX Runtime.

11,465

ARCHIVED

Pros of PHPExcel

  • Easier to use and set up for PHP developers
  • Better documentation and community support for PHP-specific use cases
  • Lighter weight and faster for simple spreadsheet operations

Cons of PHPExcel

  • Limited functionality compared to POI's extensive feature set
  • Less actively maintained (last release in 2015)
  • Performance issues with large spreadsheets

Code Comparison

PHPExcel:

$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello World');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('myfile.xlsx');

POI:

Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Sheet1");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("Hello World");
FileOutputStream out = new FileOutputStream("myfile.xlsx");
workbook.write(out);
out.close();

Both libraries allow for creating and manipulating Excel files, but POI offers more extensive features and better performance for complex operations. PHPExcel is simpler to use for basic tasks in PHP environments but lacks the robustness and ongoing development of POI. The choice between them depends on the specific project requirements, programming language preference, and the complexity of the spreadsheet operations needed.

33,890

Universal markup converter

Pros of Pandoc

  • More versatile, supporting a wider range of document formats
  • Lightweight and faster for simple document conversions
  • Better suited for academic and technical writing with LaTeX support

Cons of Pandoc

  • Less specialized for handling Microsoft Office formats
  • Limited support for complex spreadsheet operations
  • Smaller community and fewer enterprise-level features

Code Comparison

Pandoc (Haskell):

readDocx :: PandocMonad m => ReaderOptions -> B.ByteString -> m Pandoc
readDocx opts b = do
  archiveFiles <- getZipArchive b
  let contentTypesEntry = findEntryByPath "[Content_Types].xml" archiveFiles

POI (Java):

Workbook wb = WorkbookFactory.create(new File("workbook.xlsx"));
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);
System.out.println(cell.getNumericCellValue());

Pandoc excels in document format conversion and is ideal for academic writing, while POI specializes in manipulating Microsoft Office files, particularly Excel spreadsheets. Pandoc's code focuses on parsing document structures, whereas POI's code demonstrates direct interaction with spreadsheet elements. Choose Pandoc for versatile document conversions or POI for in-depth Office file manipulation.

31,958

快速、简洁、解决大文件内存溢出的java处理Excel工具

Pros of easyexcel

  • Faster processing speed and lower memory usage
  • Simpler API and easier to use for basic Excel operations
  • Built-in support for annotation-based mapping

Cons of easyexcel

  • Less comprehensive feature set compared to POI
  • Limited support for older Excel formats (mainly focuses on XLSX)
  • Smaller community and fewer third-party resources

Code Comparison

POI:

Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Sheet1");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("Hello, POI!");

easyexcel:

EasyExcel.write("output.xlsx", Data.class)
    .sheet("Sheet1")
    .doWrite(dataList);

Summary

POI is a more mature and feature-rich library with extensive support for various Microsoft Office formats. It offers greater flexibility and control but can be more complex to use and resource-intensive.

easyexcel, developed by Alibaba, focuses on simplicity and performance, particularly for large Excel files. It provides a more streamlined API for common Excel operations but may lack some advanced features found in POI.

Choose POI for comprehensive Office document manipulation or when working with older formats. Opt for easyexcel when dealing with large Excel files or if you prefer a simpler API for basic Excel operations.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Apache POI™

A Java library for reading and writing Microsoft Office binary and OOXML file formats.

The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a complete API for porting other OOXML and OLE2 formats and welcome others to participate.

OLE2 files include most Microsoft Office files such as XLS, DOC, and PPT as well as MFC serialization API based file formats. The project provides APIs for the OLE2 Filesystem (POIFS) and OLE2 Document Properties (HPSF).

Office OpenXML Format is the new standards based XML file format found in Microsoft Office 2007 and 2008. This includes XLSX, DOCX and PPTX. The project provides a low level API to support the Open Packaging Conventions using openxml4j.

For each MS Office application there exists a component module that attempts to provide a common high level Java api to both OLE2 and OOXML document formats. This is most developed for Excel workbooks (SS=HSSF+XSSF). Work is progressing for Word documents (WP=HWPF+XWPF) and PowerPoint presentations (SL=HSLF+XSLF).

The project has some support for Outlook (HSMF). Microsoft opened the specifications to this format in October 2007. We would welcome contributions.

There are also projects for Visio (HDGF and XDGF), TNEF (HMEF), and Publisher (HPBF).

This library includes the following components, roughly in descending order of maturity:

  • Excel spreadsheets (Common SS = HSSF, XSSF, and SXSSF)
  • PowerPoint slideshows (Common SL = HSLF and XSLF)
  • Word processing documents (Common WP = HWPF and XWPF)
  • Outlook email (HSMF and HMEF)
  • Visio diagrams (HDGF and XDGF)
  • Publisher (HPBF)

And lower-level, supporting components:

  • OLE2 Filesystem (POIFS)
  • OLE2 Document Properties (HPSF)
  • TNEF (HMEF) for Outlook winmail.dat files
  • OpenXML4J (OOXML)

| Components named H??F are for reading or writing OLE2 binary formats. | Components named X??F are for reading or writing OpenOffice XML (OOXML) formats.

Getting started

Website: https://poi.apache.org/

Mailing lists_:

  • Developers_
  • Users_
  • General_ (release announcements)

Bug tracker:

  • Bugzilla_
  • GitHub pull requests_

Source code:

  • Official Apache Subversion repo_ at apache.org
  • ViewVC repo browser_ at apache.org
  • GitHub git mirror_ at github.com

Requires Java 1.8 or later.

Contributing

  • Download and install svn or git, Java JDK 1.8+, and Apache Ant 1.8+ or Gradle

  • Check out the code from svn or git

  • Import the project into Eclipse or your favorite IDE

  • Write a unit test:

    • Binary formats and Common APIs: poi/src/test/java/org/apache/poi/
    • OOXML APIs only: poi-ooxml/src/test/java/org/apache/poi/
    • Scratchpad (Binary formats): poi-scratchpad/src/test/java/org/apache/poi/
    • Test files: test-data/
  • Navigate the source, make changes, and run unit tests to verify

    • Binary formats and Common APIs: poi/src/main/java/org/apache/poi/
    • OOXML APIs only: poi-ooxml/src/main/java/org/apache/poi/
    • Scratchpad (Binary formats): poi-scratchpad/src/main/java/org/apache/poi/
    • Examples: poi-examples/src/main/java/org/apache/poi/
  • More info: How To Build page_ at apache.org

Building jar files

To build the jar files for poi, poi-ooxml, poi-ooxml-lite, poi-ooxml-full and poi-examples::

./gradlew jar

gradlew jar

.. _Mailing lists: https://poi.apache.org/mailinglists.html .. _Developers: https://lists.apache.org/list.html?dev@poi.apache.org .. _Users: https://lists.apache.org/list.html?user@poi.apache.org .. _General: https://lists.apache.org/list.html?general@poi.apache.org .. _Bugzilla: https://bz.apache.org/bugzilla/buglist.cgi?product=POI .. _GitHub pull requests: https://github.com/apache/poi/pulls

.. _Apache Subversion repo: https://svn.apache.org/repos/asf/poi/trunk .. _ViewVC repo browser: https://svn.apache.org/viewvc/poi/trunk .. _GitHub git mirror: https://github.com/apache/poi .. _How To Build page: http://poi.apache.org/devel/