通过某些值的值

时间:2014-09-24 14:06:04

标签: java

我想将一个方法中的2个值传递给另一个方法,并设置一个值,其中第一个方法中的另一个值等于第二个方法中的值。

这是我的代码,我将评论我需要传递值的行:

public class updateResults {

String b1 = "48";

//String "path" is the value i want to pass
//String "number" is the value which i send to check where string "path goes"
   void updateResults(String path, String number) throws FileNotFoundException,  IOException{
    FileInputStream fis = new FileInputStream(new File(path));
    XSSFWorkbook workbook = new XSSFWorkbook (fis);
    XSSFSheet sheet = workbook.getSheetAt(0);


            XSSFRow row0 = sheet.getRow(0);
            XSSFCell cell0 = row0.getCell(0);
            XSSFCell cell1 = row0.getCell(1);
            XSSFCell cell2 = row0.getCell(2);
            XSSFCell cell3 = row0.getCell(3);
            XSSFCell cell4 = row0.getCell(4);
            XSSFCell cell5 = row0.getCell(5);
            XSSFCell cell6 = row0.getCell(6);
            XSSFCell cell7 = row0.getCell(7);
            XSSFCell cell8 = row0.getCell(8);
            XSSFCell cell9 = row0.getCell(9);
            XSSFCell cell10 = row0.getCell(10);
            XSSFCell cell11 = row0.getCell(11);
            XSSFCell cell12 = row0.getCell(12);
            XSSFCell cell13 = row0.getCell(13);
            cell0.setCellValue("1"); //If string "number" is "1" String "path" should be set to this cell
            cell1.setCellValue("2");//If string "number" is "2" String "path" should be set to this cell
            cell2.setCellValue("3");
            cell3.setCellValue("4");
            cell4.setCellValue("5");
            cell5.setCellValue("9");
            cell6.setCellValue("11");
            cell7.setCellValue("76");
            cell8.setCellValue("43");
            cell9.setCellValue("22");
            cell10.setCellValue("");
            cell11.setCellValue("");
            cell12.setCellValue("");
            cell13.setCellValue("");
    //NOTE: i have  more than 10.000 cells and they are not in ASC or DESC order.

我的java知识有限,所以我不知道如何在示例XSSFCell cell13 = row0.getCell(13);中设置XSSFCell 13 = row0.getCell(13);

任何帮助将不胜感激。

更清楚地说明:

我有两个字符串,我从一个方法发送到上面这个: 让我们说:     String path =“box”     字符串编号=“21”

我想将path设置为cell3

`cell3.setCellValue("21");`
`cell4.setCellValue("4");`
`cell4.setCellValue("15");`
`cell4.setCellValue("1532");`

0 个答案:

没有答案