title: How to check if a cell value in excel contains alt+enter using apache poi?
body: <p><a href="https://i.stack.imgur.com/rWwEC.png" rel="nofollow noreferrer">Sample Excel file I am using</a>  Below mentioned is the code i have used but it isnt working. My requirement is to separate out each test steps and store it. I have used "alt+enter" to write multiple lines in the same cell. If some how i can detect "alt+enter" while proccessing cell data with apache POI, I can easily separate my lines mentioned. </p>
  
  <pre><code>package excelExportAndFileIO;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  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.xssf.usermodel.XSSFWorkbook;
  import org.junit.Test;
  
  
  public class ExcelHelper {
  
  
      public static Map&lt;String,String&gt; GetData(String key,String sheetName) throws IOException{
          HashMap&lt;String, String&gt; hm= new HashMap&lt;String, String&gt;();
  
          try {
               List&lt;String&gt; keyList=new ArrayList&lt;&gt;();
                  List&lt;String&gt; valueList=new ArrayList&lt;&gt;();
              //String path = new File(".").getCanonicalPath();
              //String spath = "C:\\Users\\gur39708\\Documents\\INS500_TestPlan_ver2.xlsx";
              String spath = "mypath"+"\\INS500_TestPlan_ver2.xlsx";
  
              String fileExtensionName = spath.substring(spath.indexOf("."));
  
              File file =    new File(spath);
              //Create an object of FileInputStream class to read excel file
  
              FileInputStream inputStream = new FileInputStream(file);
              Workbook wb = null;
              //Find the file extension by spliting file name in substring and getting only extension name
  
  
              //Check condition if the file is xlsx file
  
              if(fileExtensionName.equals(".xlsx")){
  
              //If it is xlsx file then create object of XSSFWorkbook class
                  wb = new XSSFWorkbook(inputStream); 
  
              }
  
              //Check condition if the file is xls file
  
              else if(fileExtensionName.equals(".xls")){
  
              //If it is xls file then create object of XSSFWorkbook class
  
                  wb = new HSSFWorkbook(inputStream);
  
              }
  
  
              //Read sheet inside the workbook by its name
  
              Sheet sh = wb.getSheet(sheetName);
  
              //Get the current count of rows in excel file
  
              int rowCount = sh.getLastRowNum()+1;
  
              System.out.println("rowcount is "+rowCount);
  
            //Create a loop over all the rows of excel file to read it
              int start=0;
              for (int i = 0; i &lt; rowCount; i++) {
  
                 Row row = sh.getRow(i);
  
                  //Create a loop to print cell values in a row
  
                  for (int j = 0; j &lt; row.getLastCellNum(); j++) {
  
                      if (row.getCell(j).getStringCellValue().equals(key)){
                          String temp = row.getCell(j+1).getStringCellValue();
                          System.out.println(temp.contains("\\n"));
                      }
  
                  }
                  start ++;
  
              }    
              for(int i=0;i&lt;=keyList.size()-1;i++){
                  hm.put(keyList.get(i), valueList.get(i));
              }
  
          }catch(Exception e){
              System.out.println(e);
          }
          return hm;
      }
  
      public int getIndex(String keyword, String SheetName){
  
  
          return 0;
  
      }
  
      @Test
      public static void main(String args[]) throws IOException{
  
          Map&lt;String, String&gt; hm1= new HashMap();
          hm1 = GetData("device types","Sheet1");
          //System.out.println(hm1.size());
  
  
      }
  
  }
  </code></pre>