小编Chi*_*hid的帖子

java.io.IOException:无法读取zip输入源

FileInputStream file = new FileInputStream("/file/path/report.xlsx"); 
XSSFWorkbook wb = new XSSFWorkbook(file); --!ERROR LINE!--
Run Code Online (Sandbox Code Playgroud)

我在第二行出现错误。我看了不同的在线资源,例如:

使用Apache POI读取Excel .XLSX时出错

Exception in thread "main" java.io.IOException: Failed to read zip entry source
    at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:106)
    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:342)
    at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:285)
    at test.test.main(test.java:48)
Caused by: java.io.IOException: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the size of the expanded data. This may indicate that the file is used to inflate memory usage and thus could pose a security risk. …
Run Code Online (Sandbox Code Playgroud)

java excel apache-poi

4
推荐指数
1
解决办法
7096
查看次数

了解ZipSecureFile.setMinInflateRatio(双倍比率)

我正在使用这个函数调用,因为当我读取一个受信任的文件时,它会导致zipbomb错误.

ZipSecureFile.setMinInflateRatio(双倍比例)

   FileInputStream file = new FileInputStream("/file/path/report.xlsx"); 
   ZipSecureFile.setMinInflateRatio(-1.0d);
   XSSFWorkbook wb = new XSSFWorkbook(file);
Run Code Online (Sandbox Code Playgroud)

我想知道它是如何工作的?

我能找到的唯一来源是https://poi.apache.org/apidocs/org/apache/poi/openxml4j/util/ZipSecureFile.html

但是,由于我不熟悉这个概念,所以无法得到清晰的图像.

有什么区别

ZipSecureFile.setMinInflateRatio(-1.0d);
Run Code Online (Sandbox Code Playgroud)

VS

ZipSecureFile.setMinInflateRatio(0.009);
Run Code Online (Sandbox Code Playgroud)

VS

ZipSecureFile.setMinInflateRatio(0);
Run Code Online (Sandbox Code Playgroud)

java excel file apache-poi

3
推荐指数
1
解决办法
2683
查看次数

从特定工作表中删除最后10行 - Excel

我正在尝试从Excel文件的特定工作表(Sheet1,Sheet2和Sheet3)中删除最后10行.我试过下面的代码.

Sub Macro1()
    Dim Tables As Variant
    Dim rLastRow As Range
    Dim InxW As Long

    Tables = Array("sheet1", "sheet2", "sheet3")

    For InxW = LBound(Tables) To UBound(Tables)
        With Worksheets(Tables(InxW))
            rLastRow = Cells(Rows.Count, "A").End(xlUp)
            rLastRow.Offset(-9).Resize(10).EntireRow.Delete
        End With
    Next InxW
End Sub
Run Code Online (Sandbox Code Playgroud)

我得到的错误是在线:

rLastRow.Offset(-9).Resize(10).EntireRow.Delete
Run Code Online (Sandbox Code Playgroud)

消息:

运行时错误'91':
对象变量或未设置块变量

任何帮助表示赞赏.
提前致谢.

excel vba excel-vba

0
推荐指数
1
解决办法
352
查看次数

标签 统计

excel ×3

apache-poi ×2

java ×2

excel-vba ×1

file ×1

vba ×1