title: How do i get data from a txt file and send it to excel spreadsheet?(I only want everything after the ":" in the txt file)?
body: <p>I have a program (below) that takes txt files and puts them into an excel spreadsheet. My goal is to extract the data from a text file but only text after the colon.</p>
  
  <p>Example txt file(No space between "name:" and "phone:" lines in the txt):</p>
  
  <p>Name: John doe</p>
  
  <p>phone: (xxx) xxx-xxxx</p>
  
  <p>I want my program to only save john doe in the excel sheet and title the column "Name":
  I want my program to only save (xxx) xxx-xxxx in the excel sheet and title the column "phone" 
  I want to be able to add multiple entrys to the spreadsheet.</p>
  
  <p>Example(in excel sheet generated):This is what i want it to look like!</p>
  
  <p>....A..............B</p>
  
  <p>1   name     | Phone</p>
  
  <p>2   john doe   (123) 123-1234</p>
  
  <p>3   jack dee   (123) 123-1231</p>
  
  <p>So i looked at the string split to get only data after the ":" but cant find much documentation on it. Also getting the info to line up correctly in the excel. Any help is much appreciated.</p>
  
  <p>Thanks,
  James</p>
  
  <pre><code>package EREW;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Scanner;
  
  
  import org.apache.poi.hssf.usermodel.HSSFCell;
  import org.apache.poi.hssf.usermodel.HSSFRichTextString;
  import org.apache.poi.hssf.usermodel.HSSFRow;
  import org.apache.poi.hssf.usermodel.HSSFSheet;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  import org.apache.poi.ss.usermodel.Cell;
  import org.apache.poi.ss.usermodel.Row;
  import org.apache.poi.ss.usermodel.Sheet;
  import org.apache.poi.ss.usermodel.Workbook;
  import org.apache.poi.ss.usermodel.WorkbookFactory;
  
  
  public class ReadWriteXL
  {
  public static void main(String[] args) throws InvalidFormatException, IOException{
      ArrayList arr=new ArrayList();
  File f=new File("F:\\temp\\TEXT\\email.txt");
  
  Scanner in=new Scanner(f);
  System.out.println("Read Data From The Txt file ");
  while(in.hasNext())
  {    
  
  arr.add(in.nextLine());
  }
  System.out.println("Data From ArrayList");
  System.out.println(arr);
  
  
  System.out.println("Write data to an Excel Sheet");
  FileOutputStream fos=new FileOutputStream("F:/temp/1.xls");
  HSSFWorkbook workBook = new HSSFWorkbook();
  HSSFSheet spreadSheet = workBook.createSheet("email");
  HSSFRow row;
  HSSFCell cell;
  for(int i=0;i&lt;arr.size();i++){
      row = spreadSheet.createRow((short) i);
  cell = row.createCell(i);
  System.out.println(arr.get(i));
  cell.setCellValue(arr.get(i).toString());
  }
  System.out.println("Done");
  workBook.write(fos);
  arr.clear();
  System.out.println("ReadIng From Excel Sheet");
  
  FileInputStream fis = null;
      fis = new FileInputStream("F:/temp/1.xls");
  
      HSSFWorkbook workbook = new HSSFWorkbook(fis);
      HSSFSheet sheet = workbook.getSheetAt(0);
      Iterator rows = sheet.rowIterator();
  
      while (rows.hasNext()) {
          HSSFRow row1 = (HSSFRow) rows.next();
          Iterator cells = row1.cellIterator();
          while (cells.hasNext()) {
              HSSFCell cell1 = (HSSFCell) cells.next();
              arr.add(cell1);
          }
  }
  System.out.println(arr);
  
  }}
  </code></pre>