I am currently working on a project for my computer science class, and I was trying to figure out how to retrieve and print certain values from a file in excel. Such as, how would I go about printing the integer in column J, row 6?
Better yet, is there a way for me to return the row number of a string in column 1? Such as, if I had a string "Phone" in column 1, could I use a command to return the row number of the first instance of "phone"?
I have looked at other questions, none of which sufficiently answered my own.
Here you go refer to this class file for iterating over an excel file
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
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;
public class Test {
private static final String FILE_NAME = "/users/developer/Documents/myFile.xlsx";
public void employeesUpload() {
String fName = "";
String lName = "";
String phoneNumber = "";
String email = "";
String gender = "";
String employeeCode = "";
try {
FileInputStream excelFile = new FileInputStream(new File(FILE_NAME));
Workbook workbook = new XSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = datatypeSheet.iterator();
int rowIndex = 0;
DataFormatter formatter = new DataFormatter();
while (iterator.hasNext()) {
Row currentRow = iterator.next();
if (rowIndex > 0) {
Iterator<Cell> cellIterator = currentRow.iterator();
employeeCode = fName = lName = phoneNumber = email = gender = "";
int cellIndex = 0;
while (cellIndex <= 5) {
Cell currentCell = currentRow.getCell(cellIndex);
if (cellIndex == 4) {
employeeCode = formatter.formatCellValue(currentCell).trim();
}
if (cellIndex == 1) {
fName = formatter.formatCellValue(currentCell).trim();
}
if (cellIndex == 2) {
lName = formatter.formatCellValue(currentCell).trim();
}
if (cellIndex == 0) {
email = formatter.formatCellValue(currentCell);
email = email.trim().toLowerCase();
}
if (cellIndex == 3) {
phoneNumber = formatter.formatCellValue(currentCell).trim();
}
cellIndex++;
}
Cell resultCell = currentRow.getCell(7);
if (resultCell == null) {
resultCell = currentRow.createCell(7);
}
Cell employementIdCell = currentRow.getCell(8);
if (employementIdCell == null) {
employementIdCell = currentRow.createCell(8);
}
if (true) {
resultCell.setCellType(Cell.CELL_TYPE_STRING);
employementIdCell.setCellValue("Success");
resultCell.setCellValue(email);
} else {
resultCell.setCellType(Cell.CELL_TYPE_STRING);
resultCell.setCellValue("Error");
}
}
rowIndex++;
}
FileOutputStream outputStream = new FileOutputStream(FILE_NAME);
workbook.write(outputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws ParseException, UnsupportedEncodingException {
Test employeesBulkUpload = new Test();
employeesBulkUpload.employeesUpload();
}
}
Hope this helps :)
user https://github.com/jueyue/easypoi this jar
use annotion to easy read excel
public class ExcelImportNewDateTest {
#Test
public void importTest() {
ImportParams params = new ImportParams();
params.setTitleRows(1);
params.setHeadRows(1);
long start = new Date().getTime();
List<NewDateEntity> list = ExcelImportUtil.importExcel(
new File(FileUtilTest.getWebRootPath("import/ExcelNewDateTest.xlsx")), NewDateEntity.class, params);
System.out.println(new Date().getTime() - start);
Assert.assertEquals(list.size(), 100);
System.out.println(list.size());
System.out.println(ReflectionToStringBuilder.toString(list.get(1)));
}
}
Related
So I am trying to read an excel sheet using Java code. Below is the code:
package com.SfHawk.Utility;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ExcelApiTest {
public FileInputStream fis = null;
public XSSFWorkbook workbook = null;
public XSSFSheet sheet = null;
public XSSFRow row = null;
public XSSFCell cell = null;
public ExcelApiTest(String xlFilePath) throws Exception
{
fis = new FileInputStream(xlFilePath);
workbook = new XSSFWorkbook(fis);
fis.close();
}
public String getCellData(String sheetName, String colName, int rowNum)
{
try
{
int col_Num = -1;
sheet = workbook.getSheet(sheetName);
row = sheet.getRow(0);
for(int i = 0; i < row.getLastCellNum(); i++)
{
if(row.getCell(i).getStringCellValue().trim().equals(colName.trim()))
col_Num = i;
}
row = sheet.getRow(rowNum - 1);
cell = row.getCell(col_Num);
if(cell.getCellType() == CellType.STRING)
return cell.getStringCellValue();
else if(cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA)
{
String cellValue = String.valueOf(cell.getNumericCellValue());
if(HSSFDateUtil.isCellDateFormatted(cell))
{
DateFormat df = new SimpleDateFormat("dd/MM/yy");
Date date = cell.getDateCellValue();
cellValue = df.format(date);
}
return cellValue;
}else if(cell.getCellType() == CellType.BLANK)
return "";
else
return String.valueOf(cell.getBooleanCellValue());
}
catch(Exception e)
{
e.printStackTrace();
return "row "+rowNum+" or column "+colNum +" does not exist in Excel";
}
}
}
Above code is giving me an error saying:
Incompatible operand types int and CellType
Initially I used cell.getCellTypeEnum() method instead of cell.getCellType(). But cell.getCellTypeEnum() gave me error saying, The method getCellTypeEnum() is undefined for the type XSSFCell
How can i fix this issue?
Thanks in advance.
I am using spark-excel(com.crealytics.spark.excel) library to read excel file. If no duplicate column in excel file, the library working fine. If any duplicate column name occurs in excel file, throwing below exception.
How to overcome this error?
Is there any workaround solution to overcome this?
Exception in thread "main" org.apache.spark.sql.AnalysisException: Found duplicate column(s) in the data schema: `net territory`;
at org.apache.spark.sql.util.SchemaUtils$.checkColumnNameDuplication(SchemaUtils.scala:85)
Using spark excel API getting exception .
StructType schema = DataTypes.createStructType(new StructField[]{DataTypes.createStructField("CGISAI", DataTypes.StringType, true), DataTypes.createStructField("SALES TERRITORY", DataTypes.StringType, true)});
SQLContext sqlcxt = new SQLContext(jsc);
Dataset<Row> df = sqlcxt.read()
.format("com.crealytics.spark.excel")
.option("path", "file:///"+siteinfofile)
.option("useHeader", "true")
.option("spark.read.simpleMode", "true")
.option("treatEmptyValuesAsNulls", "true")
.option("inferSchema", "false")
.option("addColorColumns", "False")
.option("sheetName", "sheet1")
.option("startColumn", 22)
.option("endColumn", 23)
//.schema(schema)
.load();
return df;
This is the code I am using. I am using sparkexcel library from com.crealytics.spark.excel.
I want the solution to identify whether excel file has duplicate columns or not. if have duplicate columns, how to rename/eliminate the duplicate columns.
WorkAround is as below:
convert .xlsx file into .csv . using spark default csv api that can handle duplicate column names by renaming them automatically.
Below is the code to convert from xlsx to csv file.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.huawei.java.tools;
/**
*
* #author Nanaji Jonnadula
*/
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.SAXHelper;
import org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFComment;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler;
public class ExcelXlsx2Csv {
private static class SheetToCSV implements SheetContentsHandler {
private boolean firstCellOfRow = false;
private int currentRow = -1;
private int currentCol = -1;
private StringBuffer lineBuffer = new StringBuffer();
/** * Destination for data */
private FileOutputStream outputStream;
public SheetToCSV(FileOutputStream outputStream) {
this.outputStream = outputStream;
}
#Override
public void startRow(int rowNum) {
/** * If there were gaps, output the missing rows: * outputMissingRows(rowNum - currentRow - 1); */
// Prepare for this row
firstCellOfRow = true;
currentRow = rowNum;
currentCol = -1;
lineBuffer.delete(0, lineBuffer.length()); //clear lineBuffer
}
#Override
public void endRow(int rowNum) {
lineBuffer.append('\n');
try {
outputStream.write(lineBuffer.substring(0).getBytes());
} catch (IOException e) {
System.out.println("save date to file error at row number: {}"+ currentCol);
throw new RuntimeException("save date to file error at row number: " + currentCol);
}
}
#Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
if (firstCellOfRow) {
firstCellOfRow = false;
} else {
lineBuffer.append(',');
}
// gracefully handle missing CellRef here in a similar way as XSSFCell does
if (cellReference == null) {
cellReference = new CellAddress(currentRow, currentCol).formatAsString();
}
int thisCol = (new CellReference(cellReference)).getCol();
int missedCols = thisCol - currentCol - 1;
if (missedCols > 1) {
lineBuffer.append(',');
}
currentCol = thisCol;
if (formattedValue.contains("\n")) {
formattedValue = formattedValue.replace("\n", "");
}
formattedValue = "\"" + formattedValue + "\"";
lineBuffer.append(formattedValue);
}
#Override
public void headerFooter(String text, boolean isHeader, String tagName) {
// Skip, no headers or footers in CSV
}
}
private static void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings,
SheetContentsHandler sheetHandler, InputStream sheetInputStream) throws Exception {
DataFormatter formatter = new DataFormatter();
InputSource sheetSource = new InputSource(sheetInputStream);
try {
XMLReader sheetParser = SAXHelper.newXMLReader();
ContentHandler handler = new XSSFSheetXMLHandler(
styles, null, strings, sheetHandler, formatter, false);
sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource);
} catch (ParserConfigurationException e) {
throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
}
}
public static void process(String srcFile, String destFile,String sheetname_) throws Exception {
File xlsxFile = new File(srcFile);
OPCPackage xlsxPackage = OPCPackage.open(xlsxFile.getPath(), PackageAccess.READ);
ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(xlsxPackage);
XSSFReader xssfReader = new XSSFReader(xlsxPackage);
StylesTable styles = xssfReader.getStylesTable();
XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
int index = 0;
while (iter.hasNext()) {
InputStream stream = iter.next();
String sheetName = iter.getSheetName();
System.out.println(sheetName + " [index=" + index + "]");
if(sheetName.equals(sheetname_)){
FileOutputStream fileOutputStream = new FileOutputStream(destFile);
processSheet(styles, strings, new SheetToCSV(fileOutputStream), stream);
fileOutputStream.flush();
fileOutputStream.close();
}
stream.close();
++index;
}
xlsxPackage.close();
}
public static void main(String[] args) throws Exception {
ExcelXlsx2Csv.process("D:\\data\\latest.xlsx", "D:\\data\\latest.csv","sheet1"); //source , destination, sheetname
}
}
I am trying to read few csv files which are present inside a folder and putting the absolute paths inside a list and then looping to the list and inserting data into excel in different sheets but for some reason only last loop is overwriting everything.
package excel;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class FileReading {
public static void csvToXLS(String filename, String sheetno) {
try {
String csvFile = filename; //csv file address
String excelFile = "E:\\test.xls"; //xlsx file address
HSSFWorkbook workBook = new HSSFWorkbook();
HSSFSheet sheet = workBook.createSheet(sheetno);
String currentLine = null;
int RowNum = 0;
BufferedReader br = new BufferedReader(new FileReader(csvFile));
while ((currentLine = br.readLine()) != null) {
String str[] = currentLine.split(",");
HSSFRow currentRow = sheet.createRow(RowNum);
RowNum++;
for (int i = 0; i < str.length; i++) {
currentRow.createCell(i).setCellValue(str[i]);
}
}
FileOutputStream fileOutputStream = new FileOutputStream(excelFile);
workBook.write(fileOutputStream);
fileOutputStream.close();
System.out.println("Done");
} catch (Exception ex) {
System.out.println(ex.getMessage() + "Exception in try");
}
}
public static List listOfFiles() {
List<String> results = new ArrayList<String>();
File[] files = new File("f:\\csv").listFiles();
for (File file : files) {
if (file.isFile()) {
results.add(file.getAbsolutePath());
}
}
return results;
}
public static void main(String[] args) {
List list = listOfFiles();
int size = list.size();
for (int i = 0; i < size; i++) {
csvToXLS(list.get(i).toString(), "sheet" + i + 1);
}
}
}
You're re-creating and saving the Workbook every time you call csvToXLS, so only the last call survives, overwriting all others.
Create the Workbook only once, before you start your for loop, passing it into csvToXLS. then that method will create a new Sheet on an existing Workbook. Then after the for loop ends, you can write out and save the Workbook.
I did this thanks for the idea #rgettman
package excel;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class CsvToXlx {
public static void csvToXLSX(HSSFWorkbook workBook,String filename, String sheetno) {
try {
String csvFile = filename; //csv file address
String excelFile = "E:\\test.xls"; //xlsx file address
//HSSFWorkbook workBook = new HSSFWorkbook();
HSSFSheet sheet = workBook.createSheet(sheetno);
String currentLine = null;
int RowNum = 0;
BufferedReader br = new BufferedReader(new FileReader(csvFile));
while ((currentLine = br.readLine()) != null) {
String str[] = currentLine.split(",");
HSSFRow currentRow = sheet.createRow(RowNum);
RowNum++;
for (int i = 0; i < str.length; i++) {
currentRow.createCell(i).setCellValue(str[i]);
}
}
FileOutputStream fileOutputStream = new FileOutputStream(excelFile);
workBook.write(fileOutputStream);
fileOutputStream.close();
System.out.println("Done");
} catch (Exception ex) {
System.out.println(ex.getMessage() + "Exception in try");
}
}
public static List listOfFiles() {
List<String> results = new ArrayList<String>();
File[] files = new File("f:\\csv").listFiles();
for (File file : files) {
if (file.isFile()) {
results.add(file.getAbsolutePath());
}
}
return results;
}
public static void main(String[] args) {
List list = listOfFiles();
int size = list.size();
HSSFWorkbook workBook = new HSSFWorkbook();
for (int i = 0; i < size; i++) {
csvToXLSX(workBook,list.get(i).toString(), "sheet" + i + 1);
}
}
}
Below is my code.Whne i input url from excel most of the time it shows org.openqa.selenium.ElementNotVisibleException: Element is not currently visible error.
For site like www.travelocity.com it shows after clicking 7 8 links but for www.google.com it shows error from starting.
package test;
import java.awt.HeadlessException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.poi.hssf.usermodel.HSSFCell;
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.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Linktestparam {
public static void main( String[] args ) throws Exception{
Properties prop = new Properties();
FileInputStream f = new FileInputStream("C:\\Documents and Settings\\bibekananda.sarangi\\workspace\\test\\src\\excelPath");
prop.load(f);
String[][] steps ;
steps = excelRead(prop.getProperty("Linkpath"));
int totallink;
for(int j = 1; j <= steps.length ; j++){
//System.out.println("no of links in " + steps[j][0] + "is" + totallink);
totallink = linktest(steps[j][0]);
}
}
public static int linktest(String url) throws Exception{
WebDriver driver = new FirefoxDriver();
driver.navigate().to(url);
Thread.sleep(12000);
//WebDriverWait wait = new WebDriverWait(driver,60);
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("gsr")));
List<WebElement> alllinkspresent=driver.findElements(By.tagName("a"));
int totallink = driver.findElements(By.tagName("a")).size();
System.out.println("no of links in " + totallink);
for (int i = 0; i < totallink; i++)
{
int LastRow = i;
driver.findElements(By.tagName("a")).get(i).getText();
driver.findElements(By.tagName("a")).get(i).click();
System.out.println("LastRow value is" + LastRow);
Thread.sleep(18000);
String pagetitle = driver.getTitle();
System.out.println(pagetitle);
String urltext=driver.getCurrentUrl();
System.out.println(urltext);
if(pagetitle.contains("404")) {
System.out.println("404 Found");
System.out.println("FAIL");
String status="FAIL";
excelwrite(status,urltext,LastRow);
}
else{
System.out.println("PASS");
String status = "PASS";
excelwrite(status,urltext,LastRow);
driver.navigate().back();
Thread.sleep(4000);
}
}
return totallink;
//driver.close();
}
public static String[][] excelRead(String fileName) throws Exception {
File excel = new File(fileName);
FileInputStream fis = new FileInputStream(excel);
HSSFWorkbook wb = new HSSFWorkbook(fis);
HSSFSheet ws = wb.getSheet("Sheet1");
int rowNum = ws.getLastRowNum() + 1;
int colNum = ws.getRow(0).getLastCellNum();
String[][] data = new String[rowNum][colNum];
for (int i = 0 ; i < rowNum ; i++) {
HSSFRow row = ws.getRow(i);
for (int j=0 ; j < colNum ; j++){
HSSFCell cell = row.getCell(j);
String value = cellToString(cell);
data[i][j] = value;
System.out.println("The value is" + value);
}
}
return data;
}
public static String[][] excelwrite(String status,String urltext,int LastRow) throws Exception {
try{
FileInputStream file = new FileInputStream(new File("D:\\Work\\link.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(1);
Row row = sheet.createRow(LastRow);
System.out.println("LastRow value in excelwrite is " + LastRow);
Cell cell2 = row.createCell(0);
Cell cell3 = row.createCell(1);
cell3.setCellValue(status);
cell2.setCellValue(urltext);
System.out.println(status);
file.close();
FileOutputStream outFile =new FileOutputStream(new File("D:\\Work\\link.xls"));
workbook.write(outFile);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
catch (HeadlessException e)
{
e.printStackTrace();
}
return null;
}
public static String cellToString(HSSFCell cell) {
int type;
Object result ;
type = cell.getCellType();
switch (type) {
case 0 :
result = cell.getNumericCellValue();
break;
case 1 :
result = cell.getStringCellValue();
break;
default :
throw new RuntimeException("There are no support for this type of cell");
}
return result.toString();
}
}
============================
OUTPUT:::::::::::
The value isurl
The value ishttps://www.google.co.in/
The value ishttp://www.espire.com/contact-us
The value ishttp://www.travelocity.com/
no of links in 44
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 0 milliseconds
You need to use WebdriverWait for visibility of elements Code:
new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.xpath("Xpath"));
I am using poi-3.8-20120326.jar and Excel 2007, trying to collect all the cell value in one list.
I am using formula for date increment operation. For example: =(i2+3) for k2 cell.
While evaluating this formula through my java code returns #VALUE! (i2 is a date cell.)
Without source it's hard to guess what's wrong, but I think that are two things that you may forget.
1) FormulaEvaluator
2) DataFormatter
Take a look at example.
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
public class CellReader {
private Workbook workbook;
private DataFormatter formatter;
private FormulaEvaluator evaluator;
private void openWorkbook(String file) throws FileNotFoundException,
IOException, InvalidFormatException {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
workbook = WorkbookFactory.create(fis);
evaluator = workbook.getCreationHelper().createFormulaEvaluator();
formatter = new DataFormatter(true);
} finally {
if (fis != null) {
fis.close();
}
}
}
private void printXLSX() {
Sheet sheet = null;
Row row = null;
Cell cell = null;
int lastRowNum;
int lastCellNum;
sheet = workbook.getSheetAt(0);
lastRowNum = sheet.getLastRowNum();
for (int j = 0; j <= lastRowNum; j++) {
row = sheet.getRow(j);
if (row == null) {
continue;
}
lastCellNum = row.getLastCellNum();
for (int k = 0; k <= lastCellNum; k++) {
cell = row.getCell(k);
if (cell == null) {
continue;
}
if (cell.getCellType() != Cell.CELL_TYPE_FORMULA) {
System.out.println(formatter.formatCellValue(cell));
} else {
System.out.println(formatter.formatCellValue(cell,evaluator));
}
}
}
}
public static void main(String[] args) {
CellReader converter = null;
try {
converter = new CellReader();
converter.openWorkbook("a.xlsx");
converter.printXLSX();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}