Git Product home page Git Product logo

poi's Introduction

Apache POI

License PRs Welcome GitHub stars GitHub forks

Docs

Getting Started

Step 1: Download

git clone https://github.com/T5750/poi.git
cd poi

Step 2: Start Server

docker-compose up -d
# or
mvn clean spring-boot:run

http://localhost:8080/poi

Tests

  • TestReadExcel, TestReadExcelDemo
  • TestExportExcel, TestExportExcel2007, TestWriteExcelDemo
  • TestTemplate, TestExcelReplace
  • CalendarDemo
  • TestExcelFormulaDemo, TestExcelStylingDemo, TestAll

Runtime Environment

Classes

  1. HSSF, XSSF and XSSF classes

Apache POI main classes usually start with either HSSF, XSSF or SXSSF.

  • HSSF – is the POI Project’s pure Java implementation of the Excel ’97(-2007) file format. e.g. HSSFWorkbook, HSSFSheet.
  • XSSF – is the POI Project’s pure Java implementation of the Excel 2007 OOXML (.xlsx) file format. e.g. XSSFWorkbook, XSSFSheet.
  • SXSSF (since 3.8-beta3) – is an API-compatible streaming extension of XSSF to be used when very large spreadsheets have to be produced, and heap space is limited. e.g. SXSSFWorkbook, SXSSFSheet. SXSSF achieves its low memory footprint by limiting access to the rows that are within a sliding window, while XSSF gives access to all rows in the document.
  1. Row and Cell

Apart from above classes, Row and Cell are used to interact with a particular row and a particular cell in excel sheet.

  1. Style Classes

A wide range of classes like CellStyle, BuiltinFormats, ComparisonOperator, ConditionalFormattingRule, FontFormatting, IndexedColors, PatternFormatting, SheetConditionalFormatting etc. are used when you have to add formatting in a sheet, mostly based on some rules.

  1. FormulaEvaluator

Another useful class FormulaEvaluator is used to evaluate the formula cells in excel sheet.

Write an excel file

  1. Create a workbook
  2. Create a sheet in workbook
  3. Create a row in sheet
  4. Add cells in sheet
  5. Repeat step 3 and 4 to write more data

Read an excel file

  1. Create workbook instance from excel sheet
  2. Get to the desired sheet
  3. Increment row number
  4. iterate over all cells in a row
  5. repeat step 3 and 4 until all data is read

Getting Help

Having trouble with T5750's POI? We’d like to help!

Branch

References

License

This project is Open Source software released under the Apache 2.0 license.

poi's People

Contributors

dependabot[bot] avatar t5750 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poi's Issues

Cell Styles are not updating

Hi, I set a cell alignment to the right & after setting the style to one cell I updated the alignment of a style to the left.
But I'm getting both the cell's alignment left in the output. Could you help me to fix this?

`CellStyle style1 = wb.createCellStyle();
style1.setAlignment(CellStyle.ALIGN_RIGHT);

HSSFCell hssfCell = row1.createCell(j);
String val = "200";
hssfCell.setCellValue(Integer.parseInt(val));
hssfCell.setCellStyle(style1);

HSSFCell hssfCell2 = row1.createCell(j);
val = "300";
hssfCell2.setCellValue(Integer.parseInt(val));
style1.setAlignment(CellStyle.ALIGN_LEFT);
hssfCell2.setCellStyle(style1);`

Thanks in advance

`xlookup` doesn't register as a FuncVarPtg

For some reason the parser recognizes lookup but not xlookup, even though xlookup is supposed to be supported.

Code:

System.out.println("Parse \"LOOKUP(E76,$A$13:$A$41,$F$13:$F$41)\"");
for (Ptg ptg : FormulaParser.parse("LOOKUP(E76,$A$13:$A$41,$F$13:$F$41)", ewb, FormulaType.CELL, wb.getSheetIndex(sheet))) {
    System.out.println(ptg);
}
System.out.println("Parse \"XLOOKUP(E76,$A$13:$A$41,$F$13:$F$41)\"");
for (Ptg ptg : FormulaParser.parse("XLOOKUP(E76,$A$13:$A$41,$F$13:$F$41)", ewb, FormulaType.CELL, wb.getSheetIndex(sheet))) {
    System.out.println(ptg);
}

Output:

Parse "LOOKUP(E76,$A$13:$A$41,$F$13:$F$41)"
{   /* RefPtg */
	  "row": 75 /* 0x0000004b */
	, "rowRelative": true
	, "column": 4
	, "colRelative": true
	, "formatReference": "E76"
}
{   /* AreaPtg */
	  "firstRow": 12 /* 0x0000000c */
	, "firstRowRelative": false
	, "firstColumn": 0
	, "firstColRelative": false
	, "lastRow": 40 /* 0x00000028 */
	, "lastRowRelative": false
	, "lastColumn": 0
	, "lastColRelative": false
	, "formatReference": "$A$13:$A$41"
}
{   /* AreaPtg */
	  "firstRow": 12 /* 0x0000000c */
	, "firstRowRelative": false
	, "firstColumn": 5
	, "firstColRelative": false
	, "lastRow": 40 /* 0x00000028 */
	, "lastRowRelative": false
	, "lastColumn": 5
	, "lastColRelative": false
	, "formatReference": "$F$13:$F$41"
}
{   /* FuncVarPtg */
	  "functionIndex": 28 /* 0x001c */
	, "functionName": "LOOKUP"
	, "numberOfOperands": 3
	, "externalFunction": false
	, "defaultOperandClass": 32 /* 0x20 */
	, "cetab": false
}
Parse "XLOOKUP(E76,$A$13:$A$41,$F$13:$F$41)"
{   /* NameXPxg */
	  "externalWorkbookNumber": -1 /* 0xffffffff */
	, "sheetName": null
	, "nameName": "XLOOKUP"
}
{   /* RefPtg */
	  "row": 75 /* 0x0000004b */
	, "rowRelative": true
	, "column": 4
	, "colRelative": true
	, "formatReference": "E76"
}
{   /* AreaPtg */
	  "firstRow": 12 /* 0x0000000c */
	, "firstRowRelative": false
	, "firstColumn": 0
	, "firstColRelative": false
	, "lastRow": 40 /* 0x00000028 */
	, "lastRowRelative": false
	, "lastColumn": 0
	, "lastColRelative": false
	, "formatReference": "$A$13:$A$41"
}
{   /* AreaPtg */
	  "firstRow": 12 /* 0x0000000c */
	, "firstRowRelative": false
	, "firstColumn": 5
	, "firstColRelative": false
	, "lastRow": 40 /* 0x00000028 */
	, "lastRowRelative": false
	, "lastColumn": 5
	, "lastColRelative": false
	, "formatReference": "$F$13:$F$41"
}
{   /* FuncVarPtg */
	  "functionIndex": 255 /* 0x00ff */
	, "functionName": "#external#"
	, "numberOfOperands": 4
	, "externalFunction": true
	, "defaultOperandClass": 32 /* 0x20 */
	, "cetab": false
}

Apache POI is a trademark owned by the Apache Software Foundation

It is generally accepted that you can't infringe on trademarks owned by other legal entities. Could you rename this project?

Apache is also a registered trademark owned by the Apache Software Foundation. I think you need to update this repo and the docs in https://poix.readthedocs.io/en/latest/ to highlight that you have no affiliation whatsoever to Apache POI or the Apache Software Foundation.

I have brought this to the attention of the Apache Software Foundation team in charge of the Apache Software Foundation trademarks.

报错:Text length was 22 but the last format index was 28

有时会出现这行代码构建的TreeMap<Integer, CTRPrElt> formats = this.getFormatMap(this.st)的最大值与原text的长度不符合,报错:
java.lang.IllegalArgumentException: Text length was 22 but the last format index was 28
org.apache.poi.xssf.usermodel.XSSFRichTextString.buildCTRst(XSSFRichTextString.java:576) ~[poi-ooxml-3.17.jar:3.17]
org.apache.poi.xssf.usermodel.XSSFRichTextString.applyFont(XSSFRichTextString.java:156) ~[poi-ooxml-3.17.jar:3.17]
org.apache.poi.xssf.usermodel.XSSFRichTextString.applyFont(XSSFRichTextString.java:166) ~[poi-ooxml-3.17.jar:3.17]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.