Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何编程来保存一堆“文件”;。xls";Excel中的文件_Java_Python_Excel_Apache Poi_Poi Hssf - Fatal编程技术网

Java 如何编程来保存一堆“文件”;。xls";Excel中的文件

Java 如何编程来保存一堆“文件”;。xls";Excel中的文件,java,python,excel,apache-poi,poi-hssf,Java,Python,Excel,Apache Poi,Poi Hssf,我需要处理大量的.xls文件,这些文件来自这个名为Aperio的显微图像分析软件(使用Aperio进行分析后,它允许您以“只读”xls格式导出数据。在Mac上,“另存为”仅在Excel中工作,在windows机器上,“另存为”和“另存为”按钮变灰,因为这些文件受到保护)。不幸的是,这些文件的头不是标准的OLE2格式。因此,除非在Microsoft Excel中手动加载并逐个另存为.xls,否则无法使用Java API POI获取它们 由于目录中有这么多,手动执行“另存为”将非常痛苦。有没有办法编

我需要处理大量的.xls文件,这些文件来自这个名为Aperio的显微图像分析软件(使用Aperio进行分析后,它允许您以“只读”xls格式导出数据。在Mac上,“另存为”仅在Excel中工作,在windows机器上,“另存为”和“另存为”按钮变灰,因为这些文件受到保护)。不幸的是,这些文件的头不是标准的OLE2格式。因此,除非在Microsoft Excel中手动加载并逐个另存为.xls,否则无法使用Java API POI获取它们

由于目录中有这么多,手动执行“另存为”将非常痛苦。有没有办法编写一个Java程序来自动将这些文件保存为标准xls文件?如果Java不可能,还有什么其他语言可以处理这种情况,Python

编辑:

我在hex reader中加载了一个文件,如下所示:
09 04 06 00 07 00 10 00 00 00 00 00 05 4D 44 41 80 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 02 00 22 00 1E 04 0A 00 00 07 47 65 6E 65 72 61 6C 1E 04 04 00 00 01 30 1E 04 00 00 00 04 30 1E 04 08 00 00 00 05 23 2C 23 30 1E 04 0B 00 00 00 00 08 23 2C 23 30 2E 30 30 1E 04 18 00 00 00 00 15 23 2C 23 30 5F F0 5F 2E 3B 5F 2E 1E 04 1D 00 00 01 2C 23 23 30 5F F0 5F 2E 5F 5F 2E 1E 04 1D 1D 00 01 2C 23 23 23 23 30 5F F0 5F 2E 5B 52 65 64 5D 5D 5F2D 23 2C 23 23 30 5F F0 5F 2E 04 1E 00 00 00 1B 23 2C 23 30 2E 30 5F F0 5F 2E 3B 5C 2D 23 2C 23 30 2E 30 5F F0 5F 2E 04 23 00 00 00 00 20 23 2C 23 30 2E 30 30 5F F0 5F 2E 3B 52 65 64 5D 5C 2D 23 2C 23 30 2E 30 30 5F F0 5F 2E 04 18 00 00 00 00 15 2C 23 23 23 30 22 F0 22 2E 22 5F 2D 23 2C 23 23 23 23 23 22 F0 22 01 0100 1A 23 2C 23 23 30 22 F0 2E 22 3B 5B 52 65 64 5D 5C 2D 23 2C 23 30 22 F0 2E 22 1E 04 1E 00 1B 23 2C 23 23 30 2E 30 22 F0 2E 22 3B 5C 2D 23 2C 23 30 2E 30 22 F0 22 1E 04 23 00 00 20 2C 23 30 2E 30 30 22 F0 22 3B 5E 52 65 64 5D 5C 2D 23 2C 23 30 23 30 2E 30 22 F0 22 1E 04 05 00 02 25 1E 04 08 00 0005 30 2E 30 30 25 1E 04 0B 00 00 08 30 2E 30 30 45 2B 30 1E 04 0A 00 00 00 07 23 22 20 22 2F 2F 3F 1E 04 00 00 06 23 20 22 3F 3F 1E 04 0D 00 00 00 00 0A 64 64 2F 6D 2F 79 79 1E 04 0C 00 00 09 64 6 D 6 D 2 F 79 1E 04 09 00 00 00 06 64 6D 6 D 1E 04 09 00 00 00 00 06 06 06 06 06 D 6 D 6 D 6 D 2 F 79 79 1E 04 09 00 00 00 00 00 06 06 B6D 6D 5C 20 41 4D 2F 50 4D 1E 04 11 00 00 00 00 0E 68 3A 73 5C 20 41 4D 2F 50 4D 1E 04 00 00 00 04 68 3A 6D 1E 04 0A 00 00 00 00 07 68 3A 6D 6D 3A 73 1E 04 13 00 00 00 10 64 2F 6 D 2 79 79 79 5C 20 68 3A 6D 1E 04 0B 00 00 00 00 08 23 30 30 45 30 30 30 1E 04 08 00 00 00 00 05 6D 6D 3A 73 04 03 03 03 03 03 03 04 04 04 03 03 03 00 00 01 1E 04 0100 00 00 33 5F 2D 2A 20 23 2C 23 30 22 F0 2E 22 5F 2D 3B 5C 2D 2A 20 23 2C 23 30 22 F0 2E 22 5F 2D 3B 20 22 2D 22 F0 2E 22 5F 2D 3B 5F 2D 40 5F 1E 04 36 00 00 00 33 5F 2D 2A 20 23 2C 23 23 30 5F F0 5F 2D 3B 5F 2D 3B 5F 2E 5F 5F 2E 5F 2D 3B 20 22 2D 22 5F F0 5F 5F 5F 5F 2D 3B 20 20 22 2D 22 5F 5F F0 5F 5F 5F 2D 5F 5F 5F 2D 3B 0400 00 3B 5F 2D 2A 20 23 2C 23 23 30 2E 30 22 F0 2E 22 5F 2D 3B 5C 2D 2A 20 23 2C 23 23 30 2E 30 22 F0 2E 22 5F 2D 3B 5F 2D 2A 20 22 2F 22 F0 2E 22 5F 2D 3B 5F 2D 40 5F 1E 04 3E 00 00 00 3B 5F 2D 2A 20 23 2C 23 30 2E 30 5F F0 5F 2D 3B 5F 2A 20 23 2C 23 23 30 2E 30 5F F0 5F 2D 2A 20 23 2C 2 5F 2F 2D 3B 22 5F 2D 3B 22 5F 2D 3B 22 3B 2F 2F 30 5F 2D 3B 30 5F 22 3B 2F 3B 3B 2F3F 5F F0 5F 2E 5F 2D 3B 5F 2D 40 5F 2D 31 00 14 00 A0 00 00 00 08 00 0D 4D 53 20 53 61 6 6 E 73 20 53 65 72 69 66 31 00 14 00 A0 00 00 00 00 00 00 00 0E 00 0 D 53 20 53 61 6 E 73 20 53 65 72 66 31 00

你反对只用Excel宏来做吗?VBA不是很优雅,但它适用于所有与Excel文件操作相关的事情。这是在目录中搜索.xls文件、创建新目录并在新目录中重新保存这些.xls文件的代码:

Sub Resave_Files()

    ' Directory to search for .xls files.
    file_directory = "C:\Bobby\Temp"

    ' Create a temporary directory to save files.
    temp_directory = ActiveWorkbook.Path & "\Temp"
    If Dir(temp_directory, vbDirectory) = "" Then
         MkDir temp_directory
    End If

    ' Resave each .xls file in the temporary directory.
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(file_directory)
    For Each f1 In f.Files
        If (Right(f1.Name, Len(".xls")) = ".xls") Then
            wb_name = ActiveWorkbook.Name
            Set data_wb = Workbooks.Open(f1.Name)
            New_Name = temp_directory + "\" + Left(f1.Name, InStr    (f1.Name, ".xls") - 1) + "_new.xlsx"
            data_wb.SaveAs Filename:=New_Name
            data_wb.Close SaveChanges:=False
        End If
    Next

End Sub

您是否反对仅使用Excel宏执行此操作?VBA不是很优雅,但它适用于所有与Excel文件操作相关的事情。这是在目录中搜索.xls文件、创建新目录并在新目录中重新保存这些.xls文件的代码:

Sub Resave_Files()

    ' Directory to search for .xls files.
    file_directory = "C:\Bobby\Temp"

    ' Create a temporary directory to save files.
    temp_directory = ActiveWorkbook.Path & "\Temp"
    If Dir(temp_directory, vbDirectory) = "" Then
         MkDir temp_directory
    End If

    ' Resave each .xls file in the temporary directory.
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(file_directory)
    For Each f1 In f.Files
        If (Right(f1.Name, Len(".xls")) = ".xls") Then
            wb_name = ActiveWorkbook.Name
            Set data_wb = Workbooks.Open(f1.Name)
            New_Name = temp_directory + "\" + Left(f1.Name, InStr    (f1.Name, ".xls") - 1) + "_new.xlsx"
            data_wb.SaveAs Filename:=New_Name
            data_wb.Close SaveChanges:=False
        End If
    Next

End Sub

您是否反对仅使用Excel宏执行此操作?VBA不是很优雅,但它适用于所有与Excel文件操作相关的事情。这是在目录中搜索.xls文件、创建新目录并在新目录中重新保存这些.xls文件的代码:

Sub Resave_Files()

    ' Directory to search for .xls files.
    file_directory = "C:\Bobby\Temp"

    ' Create a temporary directory to save files.
    temp_directory = ActiveWorkbook.Path & "\Temp"
    If Dir(temp_directory, vbDirectory) = "" Then
         MkDir temp_directory
    End If

    ' Resave each .xls file in the temporary directory.
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(file_directory)
    For Each f1 In f.Files
        If (Right(f1.Name, Len(".xls")) = ".xls") Then
            wb_name = ActiveWorkbook.Name
            Set data_wb = Workbooks.Open(f1.Name)
            New_Name = temp_directory + "\" + Left(f1.Name, InStr    (f1.Name, ".xls") - 1) + "_new.xlsx"
            data_wb.SaveAs Filename:=New_Name
            data_wb.Close SaveChanges:=False
        End If
    Next

End Sub

您是否反对仅使用Excel宏执行此操作?VBA不是很优雅,但它适用于所有与Excel文件操作相关的事情。这是在目录中搜索.xls文件、创建新目录并在新目录中重新保存这些.xls文件的代码:

Sub Resave_Files()

    ' Directory to search for .xls files.
    file_directory = "C:\Bobby\Temp"

    ' Create a temporary directory to save files.
    temp_directory = ActiveWorkbook.Path & "\Temp"
    If Dir(temp_directory, vbDirectory) = "" Then
         MkDir temp_directory
    End If

    ' Resave each .xls file in the temporary directory.
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(file_directory)
    For Each f1 In f.Files
        If (Right(f1.Name, Len(".xls")) = ".xls") Then
            wb_name = ActiveWorkbook.Name
            Set data_wb = Workbooks.Open(f1.Name)
            New_Name = temp_directory + "\" + Left(f1.Name, InStr    (f1.Name, ".xls") - 1) + "_new.xlsx"
            data_wb.SaveAs Filename:=New_Name
            data_wb.Close SaveChanges:=False
        End If
    Next

End Sub

使用JODConverter。您有一个Excel 4.0文件;对于Apache POI来说太旧。

使用JODConverter。您有一个Excel 4.0文件;对于Apache POI来说太旧。

使用JODConverter。您有一个Excel 4.0文件;对于Apache POI来说太旧。

使用JODConverter。您有一个Excel 4.0文件;对于ApachePOI来说太旧了。

既然您提到了Python,那么您可以使用它来读取文件(它声称支持非常旧的Excel文件)。把它们写出来可以用。为方便起见,提供了一个复制工具,用于桥接
xlrd
xlwt
。所有这些都进行了描述。值得注意的是,该页面上的是一个教程,但它同时也是所有三个软件包的实际手册。

既然您提到了Python,那么您可以使用它来读取文件(它声称支持非常旧的Excel文件)。把它们写出来