当前位置:网站首页>Problems encountered in the project (V) understanding of operating excel interface poi

Problems encountered in the project (V) understanding of operating excel interface poi

2022-04-23 13:52:00 Bald Knight

excel There are many types of data , Here only for .xlsx Discuss types

excel Format

  1. open Excel In the lower left corner, you can see sheet, One sheet It's just a page ,Excel There can be multiple sheet
  2. sheet There are many lines in row
  3. There will be many cells in each row cell

establish excel The idea of

  1. First, through ExcelWriter, This class can pass in new or existing Excel file , Operate and process the data inside
  2. Can pass XSSFWorkbook Class to create sheet
  3. And then again sheet Chinese vs row and cell Handle ( Here is the processing of cache )
  4. adopt ExcelWriter.write() Transfer data to a file . Remember flush

Problems encountered

  1. To different versions , Some methods may not be found at runtime , Something unusual happened

  2. When a file name is passed in , The file name may be transferred , Cause type error . You can use this plug-in

     <!--  Give Way maven Don't compile xls file , But still pack it  -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>xls</nonFilteredFileExtension>
                        <nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>
    
  3. new file excel Empty file , stay ExcelWriter Error reporting in incoming file .

版权声明
本文为[Bald Knight]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231351243937.html