0

テキスト領域から文字列を取得し、それを配列に変換するプログラムがあります。次に、この配列を読み取ってから Excel に書き込みます。書き込みは機能しますが、タブ スペースは考慮されません。私のコードは

    String getTextArea_1 = textArea_1.getText();
        String userHomeFolder = System.getProperty("user.home");
        File excelFile = new File(userHomeFolder, "RESULT.xls");
        try {
                    //create .xls and create a worksheet.
                    FileOutputStream fos = new FileOutputStream(excelFile);
                    HSSFWorkbook workbook = new HSSFWorkbook();
                    HSSFSheet worksheet = workbook.createSheet("My Work Sheet");

                    //Create ROW-1 ((row line number in the excel))
                    HSSFRow row1;
                    //Create COL-A from ROW-1 and set data
                    HSSFCell cellA1;

                    int rowLines = 0;
                    int colLine = 0;
                    String[] strings = getTextArea_1.split("\n");                   
                    for(String b : strings) {
                        rowLines ++;
                        row1 = worksheet.createRow(rowLines -1);
                        cellA1 = row1.createCell(colLine);
                        cellA1.setCellValue(b);

                        colLine = colLine - 1;
                        colLine ++;
                        //System.out.println(b);
                        //colLine ++;
                        //System.out.println(rowLines);
                    }

                    //Save the workbook in .xls file
                    workbook.write(fos);
                    fos.flush();
                    fos.close();
                } catch (FileNotFoundException e1) {
                    e1.printStackTrace();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
        }

表示される結果はこの画像のようなもの ここに画像の説明を入力 ですが、テキスト領域からコピーして Excel シートに貼り付ける場合は、次のようにする必要があります。これが得られる結果です。

ここに画像の説明を入力 何が恋しいですか?

ランセフの提案を使用した後、結果は1つのセル列の下にしかありません.1つの行の下にするにはどうすればよいですか?!

1746
C4A
13D06MK
GREECE 
2012-07-04
2015-07-03
2012-07-04
2015-07-03
"Yes"

rowLines と colLine で遊んでみましたが、うまくいきません。

1746                                
    C4A                         
        13D06MK                     
            GREECE                  
                2012-07-04              
                    2015-07-03          
                        2012-07-04      
                            2015-07-03  
                                "Yes"
4

1 に答える 1