("/Mouse/poi/test.xls"); wb. write (fileOut); fileOut. close ();}}
Make a simple description. In fact, you can also find out in your own test. This is the problem of setting data for merging cells.
HSSFRow rowOther = sheet. createRow (0); HSSFCell cellOther = rowOther. createCell (4); cellOther. setCellValue ("multi-row, multi-column merge"); sheet. addMergedRegion (new CellRangeAddress (0, 2, 4, 9 ));
For example, if you create 1st rows (0 represent
Simple use of POI and simple use of POI
I. Introduction
You can use the POI tool to export office files such as word, excel, and ppt.
2. Sample Code
Package com. wang. test; import java. io. file; import java. io. fileOutputStream; import java. util. calendar; import java. util. date; import org. apache. poi. hssf. u
[Java POI] 1. Use of Java POI and javapoi
Most of the time, a software application needs to generate reports in Microsoft Excel file format. Sometimes an application even wants to use an Excel file as input data. For example, an application developed by a company needs to generate its own Excel for all outputs from the finance department.
Any Java programmer is willing to output MS Office files, which can b
Many times, a software application needs to generate a report in Microsoft Excel file format. Sometimes, an application might even want to use an Excel file as input data. For example, an application developed by a company will need all the output from the Finance department to generate its own Excel.Any Java programmer willing to use the output of MS Office files can be done using pre-defined and read-only APIs.What is Apache POI?Apache
("Yyyy/mm/dd HH:mm:ss"));② decimal FormatHssfcellstyle styledouble = Workbook.createcellstyle ();Styledouble.setdataformat (Format.getformat ("#,#.00000"));"#,#.00000" means that the section and section are separated by commas, with 5 decimal places reserved③ Wrapping TextHssfcellstyle Stylewraptext = Workbook.createcellstyle ();Stylewraptext.setwraptext (TRUE);④ Specifies the width of the column: unit 1/20 pixelsSheet.setcolumnwidth (columnindex, width);⑤ Auto Column width: Automatically adjus
Use poi to read and write Excel and poi to read and write excel
For a programmer, file operations are common, especially for Excel files.
Here I will introduce a POI tool used in the project to Operate Excel. There are many concepts about POI on the Internet. For more information, you can use Baidu. Here I will just g
. setPageSize (int) to set the number of results on each page;
Query the page number through Query. setPageNum (int.
2. Send requests and receive data.
Use descriearch. searchPOIAsyn () to search for POI. Use the deleearch. setonreceivearchlistener () method to set the listener and process the returned results in the onreceivearchched (PoiResult poiResult, int rC
); Leftaxis.setcrosses (Axiscrosses.auto_zero);5. Populating data on discrete graphschartdatasourcewherein, the following method definesDatasources.fromnumericcellrange (sheet, new cellrangeaddress (0, 0, 0, num_of_columns-1));As followsAs can be seen from the above, the key method of filling the data is thatSo how does this approach be defined?Public cellrangeaddress (int firstrow, int lastrow, int firstcol, int lastcol)As can be seen from the above, it allows us to
Public static chartdatasource
As can be seen from the above, the key method of filling the data is that[Java]View PlainCopy
"code" class="java" >new Cellrangeaddress (0, 0, 0, Num_of_columns- 1) /c8>
So how does this approach be defined?[Java]View PlainCopy
Public cellrangeaddress (int firstrow, int lastrow, int firstcol, int lastcol)
As can be seen from the above, it allows us to set the data from that
(4) How to Use Apache POI to Operate Excel files ----- A regression bug in POI-3.12 was found,
It was hard to expect the final version of POI-3.12 to come out, and this month finally came out, so the first congestion was fast, download the latest POI-3.12 from this address (https://poi.apache.org/download.html#
JAVA-based Excel read/write-poi, javaexcel-poi
The previous article introduced xls. jar to generate an Excel file. This article introduces how to use poi to read and write Excel files. The content is very simple and the code annotations are clear.
1. generate an Excel file:
Import java. io. file; import java. io. fileOutputStream; import org. apache.
Poi reads the word content, and poi reads the word content
Pache POI is an open source library of the Apache Software Foundation. POI provides APIs for Java programs to read and write Microsoft Office files.
1. Read the jar packages required by word 2003 and word 2007.
Reading the 2003 documents (.doc) word file is rel
Poi enables excel reading and poi for excel reading
Public File file = new File (path );FileInputStream FCM = new FileInputStream (file );HSSFWorkbook book = new HSSFWorkbook (FCM );HSSFSheet sheet = book. getSheet (sheetName );If (sheet = null) return null;Class ArrayList Field [] fields = classType. getDeclaredFields (); // obtain the Field in the object.StartRow --;For (int I = startRow; I HSSFRow row =
A POI introductionApache POI is an open source library of the Apache Software Foundation, where POI provides APIs to Java programs for Microsoft Office format Archives Read and write functions. Since 2009-09-28, the release of the 3.5 version, providing support for Office2007;POI supports Excel, Word, and more in t
workbook = new hssfworkbook ();
Create a worksheet in an Excel worksheet named the default value. Poi also provides other workbook constructor methods. Let's take a look:
2. Create a worksheet
To create a worksheet named "payroll", the statement is:
Hssfsheet sheet = Workbook. createsheet ("payroll ");
3. Create a row
Create a row at the index 0 (the top row)
Hssfrow ROW = sheet. createrow (0 );
4. Create Cells
Create a cell (top left) at the pos
following is an example of registering an event processing handle:
Private eventrecordfactory factory = new eventrecordfactory ();Factory. registerlistener (New erflistener (){Public Boolean processrecord (record REC ){(Got BOF record );Return true;}}, New short [] {bofrecord. Sid });Factory. processrecords (someinputstream );
Vi. hssf workbook Structure
As mentioned above, hssf is based on poifs. Specifically, the Excel 97 + file is an ole 2 compound document. The underlying Ole 2 composite do
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.