用Java保存.xls文件

时间:2015-09-21 11:41:20

标签: java excel jxl

我创建了一个应用程序,可以在一个小时到一小时内读取计时器中的一些数据。我用过jxl库。

有两个Excel文件。一个是我的应用程序读取数据的另一个,另一个是人们使用它来输入第一个数据中的一些数据。该人输入的数据是在我的申请的两次读取之间输入的。这是使用Excel公式。我的问题是,当我的应用程序打开文件时,该人输入的数据无法读取。它会自动0。但是,如果我打开文件并在我的应用程序之前点击“保存”,则会读取数据。

所以我认为我需要以某种方式打开,保存并从我的代码中读取文件。我不知道如何从代码中保存文件。以下是我阅读细胞的方法:

                    o9 = sheet1.getCell(14, numCell);
                    p9 = sheet1.getCell(23, numCell);
                    x9 = sheet1.getCell(15, numCell);
                    y9 = sheet1.getCell(23, numCell);
                    z9 = sheet1.getCell(25, numCell);
                    // g6 = sheet1.getCell(6, 36);
                    //  G6 = sheet1.getCell(6, 37);
                    r9 = sheet2.getCell(17, numCell);
                    s9 = sheet2.getCell(18, numCell);
                    t9 = sheet2.getCell(19, numCell);
                    ab9 = sheet2.getCell(27, numCell);

                    try {
                        if (o9.getType() == CellType.STRING_FORMULA) {
                            FormulaCell nc14 = (FormulaCell) o9;
                            // System.out.println(o9.getContents());

                        } else {
                            alimMoara = Double.parseDouble(o9.getContents());
                        }
                    } catch (Exception e) {
                        txtComent.setText("Alim Moara hasn't been saved !");
                    }

                    if (x9.getType() == CellType.NUMBER) {
                        NumberCell nc23 = (NumberCell) x9;
                        incarcMoara = nc23.getValue();

                    }

                    try {
                        if (z9.getType() == CellType.STRING_FORMULA) {
                            FormulaCell nc24 = (FormulaCell) z9;
                            String formula = nc24.getFormula();

                        } else {
                            SSB = Double.parseDouble(z9.getContents());
                        }
                    } catch (Exception e) {
                        txtComent.append(" SSB hasn't been saved ");
                    }

                    if (r9.getType() == CellType.NUMBER) {
                        NumberCell nc17 = (NumberCell) r9;
                        ventSepA = nc17.getValue();

                    }

                    if (ab9.getType() == CellType.NUMBER) {
                        NumberCell nc27 = (NumberCell) ab9;
                        turSep = nc27.getValue();
                    }

有些想法?

0 个答案:

没有答案