text:
> [Apache POI](http://poi.apache.org/)
>
> [POI概述与操作Excel](https://www.cnblogs.com/gdwkong/p/8669220.html)

## 概述

Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。

结构:

- HSSF - 提供读写Microsoft Excel格式档案的功能。

- XSSF - 提供读写Microsoft Excel OOXML格式档案的功能。
- HWPF - 提供读写Microsoft Word格式档案的功能。
- HSLF - 提供读写Microsoft PowerPoint格式档案的功能。
- HDGF - 提供读写Microsoft Visio格式档案的功能。

## HSSF读写Excel

理解Excel中的几个名词:

- Workbook 工作簿
- Sheet 页
- Row 行
- Cell 单元格

一个工作簿包含多页,每页有多行,每行可以有多个单元格。

### 写入Excel

将一个List<VO>数据写入Excel,表头为VO的每个成员名,表体为List中的所有数据。

```java
public class ExcelWriterUtil {

    public static void writeExcel(String filePath, List<ExampleVO> voList) {
        HSSFWorkbook workbook = new HSSFWorkbook(); // 创建HSSF工作簿
        HSSFSheet sheet = workbook.createSheet(); // 创建页
        HSSFRow headerRow = sheet.createRow(0); // 创建表头
        HSSFCell cell; // 单元格

        String[] headerContent = ExampleVO.getHeaderData(); //获取表头内容
        // 表头内容填充
        for (int i = 0; i < headerContent.length; i++) {
            cell = headerRow.createCell(i);
            cell.setCellValue(headerContent[i]);
        }

        // 数据填充
        int rowNum = 1; //当前行数
        for (ExampleVO vo : voList) {
            HSSFRow dataRow = sheet.createRow(rowNum++);
            dataRow.createCell(0).setCellValue(vo.getId());
            dataRow.createCell(1).setCellValue(vo.getName());
            dataRow.createCell(2).setCellValue(vo.getPhone());
            // ... 根据VO成员数或自行决定创建多少单元格
        }

        // 输出工作簿文件
        try {
            FileOutputStream file = new FileOutputStream(filePath);
            workbook.write(file);
            file.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
```

### 读出Excel

将Excel中的数据读出,根据表头映射到对应VO中,放入List<VO>集合。

```java
public class ExcelReaderUtil {

    private static final String XLS = "xls";

    private static Workbook getWorkbook(InputStream inputStream, String fileType) throws IOException {
        Workbook workbook = null;
        if (fileType.equalsIgnoreCase(XLS)) {
            workbook = new HSSFWorkbook(inputStream);
        }
        return workbook;
    }

    public static List<ExampleVO> readExcel(String filePath) {
        Workbook workbook = null;
        FileInputStream excelFile = null;
        try {
            String fileType = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length());
            excelFile = new FileInputStream(filePath);
            workbook = getWorkbook(excelFile, fileType);
            // 获取Excel数据
            List<ExampleVO> voList = parseExcel(workbook);
            return voList;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            try {
                if (null != workbook) workbook.close();
                if (null != excelFile) excelFile.close();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    }

    private static List<ExampleVO> parseExcel(Workbook workbook) {
        List<ExampleVO> voList = new ArrayList<>();
        for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
            Sheet sheet = workbook.getSheetAt(sheetNum);

            if (null == sheet) continue;

            int headerRowNum = sheet.getFirstRowNum();
            Row headerRow = sheet.getRow(headerRowNum);
            if (null == headerRow) {
                Log.e("parseExcel", "表头数据未找到");
            }

            int rowStart = headerRowNum + 1;
            int rowEnd = sheet.getPhysicalNumberOfRows();
            for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) {
                Row row = sheet.getRow(rowNum);
                if (null == row) continue;

                ExampleVO vo = convertRowToData(row);

                if (null == data) {
                    Log.e("converRowToData", rowNum + "行数据不合法,已忽略");
                    continue;
                }
                voList.add(vo);
            }
        }

        return voList;

    }

    public static ExampleVO convertRowToData(Row row) {
        ExampleVO vo = new ExampleVO();
        Cell cell;
        int cellNum = 0;
        cell = row.getCell(cellNum++);
        vo.setId((int) cell.getNumericCellValue());

        cell = row.getCell(cellNum++);
        vo.setName((int) cell.getStringCellValue());

        cell = row.getCell(cellNum++);
        vo.setPhone((int) cell.getStringCellValue());

        return vo;
    }

}
```

redpajama_set_name: RedPajamaGithub


text:
S.I. No. 19/1964 - Fire Blight Disease Order, 1964.
S.I. No. 19 of 1964.
FIRE BLIGHT DISEASE ORDER, 1964.
I, PATRICK SMITH, Minister for Agriculture, in exercise of the powers conferred on me by section 3 of the Destructive Insects and Pests (Consolidation) Act, 1958 (No. 11 of 1958), for the purposes of preventing the spreading in the State of fire blight disease, hereby order as follows :—
1.—(1) This Order may be cited as the Fire Blight Disease Order, 1964.
(2) This Order shall come into operation on the 1st day of March, 1964.
2. In this Order—
" bees " means honey bees, and includes such bees in any stage of their life cycle ;
" fire blight disease " means the disease of fruit trees and other trees caused by the bacterium Erwinia amylovora ;
" hive " includes any receptacle used or formerly used to house a colony of bees ;
" Inspector " means an officer of the Minister or any person appointed to be an inspector for the purposes of this Order ;
" the Minister " means the Minister for Agriculture ;
" tree " includes bush and cane.
3. The owner or occupier of any land or the servant or the agent of such owner shall, if he finds that any tree present on such land is infected with fire blight disease or suspects that any such tree is so infected, forthwith notify the Minister of the fact.
4. No person shall sell, offer for sale or distribute in any manner, for planting any tree or part of a tree on which fire blight disease exists.
5.—(1) An Inspector may, upon production, if so required, of his appointment or authority, enter upon any land for the purpose of ascertaining whether fire blight disease exists on any tree thereon and if fire blight disease does exist, the extent to which it exists, and may mark any tree infected with fire blight disease and may make allsuch inquiries and examinations (including the taking of samples) as he deems necessary.
(2) An Inspector may, upon production, if so required, of his appointment or authority, enter upon any premises, vehicle, wagon, conveyance, aircraft or vessel or other craft in, on or in the vicinity of which he has reason to believe that fire blight disease exists or has existed on any tree or part of a tree and he may make all such inquiries and examinations (including the taking of samples) as he deems necessary.
6. An Inspector shall forthwith report and furnish particulars of the finding of fire blight disease on any tree to the Minister.
7.—(1) Whenever, whether through the report of an Inspector or otherwise, it comes to the knowledge of the Minister that fire blight disease exists on any tree, he may serve on the owner or the occupier of the land on which the infected tree is present a notice (in this Order referred to as a fire blight disease prevention notice) requiring the person on whom it is served to do any one or more of the following :—
(a) grub up and destroy by fire on the said land the whole of any tree specified in the notice,
(b) cut off or detach and destroy by fire on the said land a specified part of any tree mentioned in the notice,
(c) treat in such manner as may be specified in the notice the whole or any specified part of any tree mentioned in the notice,
(d) destroy by fire on the said land such fruit taken from trees growing on that land as may be specified in the notice,
(e) abstain from removing or permitting to be removed from the said land any tree, fruit, pollen, budwood, scion or other part of any tree except under and in accordance with a written direction given by the Minister or an Inspector,
(f) abstain from bringing or permitting to be brought on to the said land or removing or permitting to be removed from the said land any hive or bees except under and in accordance with a written direction given by the Minister or an Inspector,
(g) take such other steps for the prevention of the spread of fire blight disease as may be reasonably necessary and are prescribed in the notice.
(2) The Minister may serve more than one fire blight disease prevention notice on the same person.
(3) A fire blight disease prevention notice may at any time be amended, modified or withdrawn by a further notice.
8. If a tree, part of a tree, or fruit of a tree is moved, sold, used or dealt with in contravention of this Order or a notice (including a fire blight disease prevention notice) or direction served hereunder, the Minister or an Inspector may seize the tree, part of a tree or fruit and may dispose of or cause to be disposed of in such manner as the Minister or Inspector may think fit, the tree, part of a tree or fruit, or any package in which such tree, part of a tree or fruit is or has been contained, or may remove or cause to be removed to such place and in such manner as the Minister or the Inspector may think fit, the tree, part of a tree, fruit, or any such package and may serve a notice on the consignee of, or on the person in charge of, or in possession of, the tree, part of a tree, fruit or any such package, directing the person on whom the notice is served to dispose of the tree, part of a tree, fruit or package within such time and in such manner as may be specified in the notice or to remove the tree, part of a tree, fruit or package within such time and to such place as may be specified in the notice.
9. If on the expiration of fourteen days after the service on a person of a notice under this Order such person has failed to comply with the requirements of the notice, an Inspector may enter on the land referred to in the notice and may do all such things as may be necessary to comply with the notice.
10. For the purpose of this Order, a notice or a direction served hereunder shall be deemed to be served on any person if it is delivered to him personally, or left for him at his last known place of abode or business or sent in a prepaid registered letter addressed to him there and a notice purporting to be signed by an Inspector shall be prima facie evidence that it was signed by him as an Inspector.
11. Any person who, whether by act or omission, fails to comply with any provision of this Order or with any notice or with a direction, served hereunder, shall be guilty of an offence under this Order and shall be liable on summary conviction thereof to a fine not exceeding in the case of a first offence, ten pounds or in the case of a second or any subsequent offence, twenty pounds.
12. Notwithstanding anything in this Order, a tree infected with fire blight disease or a part of any such tree or the fruit of any such tree may be dealt with in the manner specified in a licence specially granted for that purpose by the Minister.
GIVEN under my Official Seal, this 4th day of February, 1964.
PATRICK SMITH.
Minister for Agriculture.
This Order requires the existence or suspected existence of fire blight disease to be notified to the Minister for Agriculture and gives the Minister certain powers with a view to preventing spread of the disease.

redpajama_set_name: RedPajamaCommonCrawl


When cold weather hits, a warm fire will do just the trick to keep you and your home nice and warm. Make sure you have a good fireplace tool set ready to stoke and tend that fire. Argyle Feed Store now have these toolsets by HomeBasix available in store.
These tending tools are essential to keep your home fireplaces safe for you and your family. This sturdy tool set has a black finish and has two handle options. One is a decorative ball and the other is loop handles which also serve to hang the tools on the stand.
Stop by Argyle Feed Store and get your fireplace tool set today!
This entry was posted on Wednesday, December 20th, 2017 at 9:31 pm	and is filed under News & Updates. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.


We spent last night in Chattanooga. In the 1960s it was voted the dirtiest city in the USA. We are not sure why, it looks OK now, but it may have been because of all the trains that ran through it.
Next we caught the 10.40am Chattanooga Choo Choo, an old steam train that does hourly trips for people who want to relive the days when trains were a major means of transport in this area. It took us a short distance, through the 1880-era Missionary Ridge tunnel (which is so narrow that the train barely fits through), and to an area where the original turntable is still running. They turned the engine and took us back to the station again. We opted to ride the unairconditioned car so we could have the windows open and smoke and soot blowing over us. It was quite a ride.
If you are ever in Bessemer, Alabama, we recommend you try Ezell's Catfish Cabin. They serve a lot of great local cuisine, including fried frog's legs. I had a great gumbo and Vyv had catfish with sweet potato fries (which came with cinnamon butter which I liked with the fries, but Vyv didn't).
Drinks are served in large preserving jars, similar to how they drink their moonshine.
We talked to a guy at a service station about legal moonshine that they were selling and he said it was awful, only 12% proof. He says that he can get the real 100% proof from almost anyone who lives in the area.