### Start Writing from Specific Row Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Specify the starting row index for writing data. This is generally not recommended as the library calculates it automatically based on whether a title is set. ```java Writer.create().start(4); ``` -------------------------------- ### Writing from a Specific Row Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Allows you to specify the starting row index for writing data. This is generally not recommended as it can lead to empty rows. ```APIDOC ## Writing from a Specific Row This option allows you to specify the starting row index for writing data. It's generally not recommended as the default behavior calculates this based on whether a title is set. If you wish to leave some rows blank before writing, you can set this. ```java Writer.create().start(4); ``` This will start writing from the row with index 4. ``` -------------------------------- ### Reader API Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Provides methods for creating a Reader, specifying the data source (file or InputStream), setting the starting row, selecting a sheet by index or name, and retrieving data as a Stream or List. ```APIDOC ## Reader - `create(Class)`: Creates a Reader for a specified type. - `from(File)`: Reads from a file. - `from(InputStream)`: Reads from an InputStream. - `startRow(int)`: Sets the starting row index for reading (0-based). - `sheet(int)`: Specifies the sheet index to read (defaults to 0). - `sheet(String)`: Specifies the sheet name to read. - `asStream()`: Returns the read data as a Stream. - `asList()`: Returns the read data as a List. ``` -------------------------------- ### Writer API Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Offers methods for creating a Writer, specifying Excel type (XLSX, XLS, CSV), providing data, setting sheet name, start row, header title, custom styles, using templates, buffer size, raw writing, append mode, and outputting to a file or OutputStream. ```APIDOC ## Writer - `Writer(ExcelType)`: Constructor to specify the Excel file type (supports XLSX, XLS, CSV). - `withRows(Collection)`: Provides the data to be written as a collection. - `sheet(String)`: Sets the name of the sheet to write to (defaults to `Sheet0`). - `startRow(int)`: Sets the starting row index for writing (0-based). Default is calculated; recommended not to set. - `headerTitle(String)`: Sets an optional main title for the sheet. - `titleStyle(BiConsumer)`: Customizes the style for the header title. - `headerStyle(BiConsumer)`: Customizes the style for the header row. - `cellStyle(BiConsumer)`: Customizes the style for cells within rows. - `withTemplate(File)`: Creates an Excel file based on a template file. - `bufferSize(int)`: Sets the buffer size for writing XLSX files (defaults to 100, recommended not to change). - `withRaw()`: Enables custom row writing, allowing manual creation of `Row` and `Cell` objects. - `createRow(int)`: Used with `withRaw()` to create custom rows and cells. - `isAppend(boolean)`: Defaults to `false`. Set to `true` to append to the file instead of overwriting. - `to(File)`: Writes the Excel document to a file. - `to(OutputStream)`: Writes the Excel document to an OutputStream. ``` -------------------------------- ### Download via Servlet Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Easily output query data directly to the browser for download using a Servlet. Simply pass the HttpServletResponse object and the desired filename. ```APIDOC ## Download via Servlet To conveniently output query data directly to the browser for download, you can use this method. This is particularly useful in servlet-based applications. ```java Writer.create() ... .to(ResponseWrapper.createXLSX(servletResponse, "xxxTable.xlsx")) ``` Pass the `HttpServletResponse` object and the desired export filename. The rest is handled automatically. ``` -------------------------------- ### Download via Servlet Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Easily export query data directly to the browser for download in Servlet-based applications. Pass the HttpServletResponse object and the desired filename. ```java Writer.create() ... .to(ResponseWrapper.createXLSX(servletResponse, "xxx表格.xlsx")) ``` -------------------------------- ### Export Using Template Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Populate a pre-designed Excel template with data. This is useful for complex or visually appealing Excel reports. The template file should be located in the classpath. ```java Writer.create() .withTemplate(classPath() + "/template.xls") .withRows(buildData()) .to(new File(fileName)); ``` -------------------------------- ### Export Using a Template Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Utilize a pre-designed template Excel file to export data, especially for complex layouts. The program fills data into the template. ```APIDOC ## Export Using a Template When you need to export Excel files with complex layouts, you can use a template file. The program will then fill in the data into this template. ```java Writer.create() .withTemplate(classPath() + "/template.xls") .withRows(buildData()) .to(new File(fileName)); ``` Note: The `template.xls` file should be located in the `classpath`. ``` -------------------------------- ### Setting Header Title Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Optionally set a main title for the Excel document, which will appear in the first row and be merged into a single column. ```APIDOC ## Setting Header Title Set a main title for the Excel document. This title will be displayed in the first row and automatically merged into a single column. ```java Writer.create().headerTitle("2018 Year May Books TOP 10"); ``` ``` -------------------------------- ### Customizing Styles Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Provides APIs to set custom styles for the header and cells, including font size, color, and alignment. Refer to POI documentation for more details. ```APIDOC ## Customizing Styles Customize the style for the header title, header row, and cells. You can set font properties like size and color. ```java Writer.create() .headerTitle("A Custom Styled Excel Sheet") .withRows(buildData()) .titleStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 40); font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); style.setFont(font); }) .headerStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 20); font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); style.setFont(font); }) .cellStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 20); font.setColor(HSSFColor.HSSFColorPredefined.BLUE.getIndex()); style.setFont(font); }) .to(new File(fileName)); ``` Refer to the POI documentation for detailed style operations: [https://poi.apache.org/spreadsheet/quick-guide.html#Creating+Date+Cells](https://poi.apache.org/spreadsheet/quick-guide.html#Creating+Date+Cells) ``` -------------------------------- ### Set Header Title Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Add a main title to the Excel sheet. This title will appear on the first row and be merged across columns. ```java Writer.create().headerTitle("2018 年 5 月 书籍 TOP 10"); ``` -------------------------------- ### Customize Sheet Name Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Change the default sheet name from 'Sheet0' to a custom name. ```java Writer.create().sheet("my_sheet"); ``` -------------------------------- ### @ExcelColumn Annotation Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Used to configure how Excel columns are read or written. Options include column index, title, date pattern, custom converter, and column width. ```APIDOC ## @ExcelColumn Annotation This annotation is used to configure the mapping of fields to Excel columns during reading and writing. | Option | Default Value | Description | |---------------|-----------------------|------------------------------------------------------------------------------------------------------------| | `index` | `-1` | Specifies the column index in the Excel sheet (0-based). Applicable for both reading and writing. | | `title` | `""` | The column name to be used when exporting to Excel (e.g., Status, Name, Phone Number). | | `datePattern` | `""` | The `pattern` for date formatting, effective for `Date`, `LocalDate`, and `LocalDateTime` types. | | `converter` | `NullConverter.class` | The `Class` of the data type converter. Implements the `Converter` interface and must have a no-arg constructor. | | `width` | `-1` | The column width when exporting to Excel. Recommended to set based on `character count * 256`. | ``` -------------------------------- ### Custom Cell and Header Styles Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Apply custom styles to the header title, header row, and data cells. This allows for customization of font size, color, and alignment. Requires POI library knowledge for advanced styling. ```java Writer.create() .headerTitle("一份自定义样式的Excel表格") .withRows(buildData()) .titleStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 40); font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); style.setFont(font); }) .headerStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 20); font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); style.setFont(font); }) .cellStyle((wb, style) -> { Font font = wb.createFont(); font.setFontHeightInPoints((short) 20); font.setColor(HSSFColor.HSSFColorPredefined.BLUE.getIndex()); style.setFont(font); }) .to(new File(fileName)); ``` -------------------------------- ### Custom Sheet Name Source: https://github.com/hellokaton/excel-plus/blob/dev/docs/README.md Allows you to specify a custom name for the sheet when writing an Excel file. Defaults to 'Sheet0'. ```APIDOC ## Custom Sheet Name Default sheet name is `Sheet0`. You can change it using the `sheet()` method. ```java Writer.create().sheet("my_sheet"); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.