Created
June 7, 2014 12:26
-
-
Save asbestos/c080f02d59cef3af8d5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main( String[] args ) { | |
try { | |
// String fName = args[ 0 ]; | |
String csvFileAddress = "C:\\Users\\psingh\\Desktop\\test\\New folder\\GenericDealerReport - version6.txt"; //csv file address | |
String xlsxFileAddress = "C:\\Users\\psingh\\Desktop\\trial\\test3.xlsx"; //xlsx file address | |
SXSSFWorkbook workBook = new SXSSFWorkbook( 1000 ); | |
org.apache.poi.ss.usermodel.Sheet sheet = workBook.createSheet( "sheet1" ); | |
String currentLine = null; | |
int RowNum = -1; | |
BufferedReader br = new BufferedReader( new FileReader( csvFileAddress ) ); | |
while ( ( currentLine = br.readLine() ) != null ) { | |
String str[] = currentLine.split( "\\|" ); | |
RowNum++; | |
Row currentRow = sheet.createRow( RowNum ); | |
for ( int i = 0; i < str.length; i++ ) { | |
currentRow.createCell( i ) | |
.setCellValue( str[ i ] ); | |
} | |
} | |
DateFormat df = new SimpleDateFormat( "yyyy-mm-dd-HHmmss" ); | |
Date today = Calendar.getInstance() | |
.getTime(); | |
String reportDate = df.format( today ); | |
FileOutputStream fileOutputStream = new FileOutputStream( xlsxFileAddress ); | |
workBook.write( fileOutputStream ); | |
fileOutputStream.close(); | |
//System.out.println( "Done" ); | |
} | |
catch ( Exception ex ) { | |
System.out.println( ex.getMessage() + "Exception in try" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment