Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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 Netbeans org.apache.poi-无法访问Date1904Support_Java_Maven_Apache Poi - Fatal编程技术网

Java Netbeans org.apache.poi-无法访问Date1904Support

Java Netbeans org.apache.poi-无法访问Date1904Support,java,maven,apache-poi,Java,Maven,Apache Poi,我正在NetBeans IDE 8.2中创建Csv2Xlsx应用程序,出现以下错误: --- maven-compiler-plugin:2.3.2:compile (default-compile) @ csv2xlsx --- Compiling 1 source file to C:\Users\test\Documents\NetBeansProjects\csv2xlsx\target\classes ------------------------------------------

我正在NetBeans IDE 8.2中创建Csv2Xlsx应用程序,出现以下错误:

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ csv2xlsx ---
Compiling 1 source file to C:\Users\test\Documents\NetBeansProjects\csv2xlsx\target\classes
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
com/test/csv2xlsx/Csv2Xlsx.java:[74,38] error: cannot access Date1904Support
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.320s
Finished at: Fri May 24 06:57:36 CEST 2019
Final Memory: 17M/347M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project csv2xlsx: Compilation failure
com/test/csv2xlsx/Csv2Xlsx.java:[74,38] error: cannot access Date1904Support
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
这是我在项目中的所有依赖项

java文件中的错误行是

XSSFSheet sheet = workBook.createSheet("Data"); // com/test/csv2xlsx/Csv2Xlsx.java:[74,38] error: cannot access Date1904Support
但是没有红色下划线,试着编译后给我这个错误

在我的Csv2Xlsw java文件中,我导入了以下名称空间:

import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;

import org.apache.log4j.Logger;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
这是我的POM文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>csv2xlsx</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.8</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <name>Csv2Xlsx</name>
    <description>Convert CSV file to Xlsx (Excel) file</description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
com.test
csv2xlsx
1
罐子
org.apache.poi
poi
3.8
罐子
log4j
log4j
1.2.16
罐子
org.apache.poi
poi ooxml
4.1.0
朱尼特
朱尼特
4.12
测试
org.hamcrest
汉克雷斯特岩芯
1.3
测试
UTF-8
1.8
1.8
Csv2Xlsx
将CSV文件转换为Xlsx(Excel)文件
org.apache.maven.plugins
maven编译器插件
2.3.2
真的
我不确定问题出在哪里

public void convert(String sourceCSV, String targetXLSX) throws IOException,
            NumberFormatException {
        try {

            XSSFWorkbook workBook = new XSSFWorkbook();
            XSSFSheet sheet = workBook.createSheet("Data"); // com/test/csv2xlsx/Csv2Xlsx.java:[74,38] error: cannot access Date1904Support
            String currentLine = null;
            int RowNum = 0;
            BufferedReader br = new BufferedReader(new FileReader(sourceCSV));

            while ((currentLine = br.readLine()) != null) {
                String str[] = currentLine.split(delimiter);
                RowNum++;
                Row currentRow = sheet.createRow(RowNum);
                for (int i = 0; i < str.length; i++) {
                    currentRow.createCell(i).setCellValue(str[i]);
                }
            }

            try (FileOutputStream fileOutputStream = new FileOutputStream(targetXLSX)) {
                workBook.write(fileOutputStream);
            }
            System.out.println("Done");
        } catch (IOException | NumberFormatException ex) {
            System.out.println(ex.getMessage() + "Exception in try");
        }
    }
public void convert(字符串sourceCSV,字符串targetXLSX)引发IOException,
数字格式异常{
试一试{
XSSFWorkbook工作簿=新XSSFWorkbook();
XSSFSheet sheet=workBook.createSheet(“数据”);//com/test/csv2xlsx/csv2xlsx.java:[74,38]错误:无法访问Date1904Support
字符串currentLine=null;
int RowNum=0;
BufferedReader br=新的BufferedReader(新文件读取器(sourceCSV));
而((currentLine=br.readLine())!=null){
字符串str[]=currentLine.split(分隔符);
RowNum++;
Row currentRow=sheet.createRow(RowNum);
对于(int i=0;i
poi和poi ooxml的版本应该相同,这样您就不会再遇到这个问题了。转到您的pom.xml以验证版本号并相应地更新它们。

您正在混合不同的
apache poi
版本。在您的例子中,
poi-3.8.jar
poi-ooxml-4.1.0.jar
poi-ooxml-schemas-4.1.0.jar
。坚持使用版本
4.1.0
。嗨,谢谢,现在我看到了,我把它改成了4.1版本