Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet How to upload a large excel file
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


harini
How to upload a large excel file
0 Answer(s)      4 years and 4 months ago
Posted in : JSP-Servlet


Dear sir ,
How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values but for large file my code is not working so please help me sir i have used u r uploadandstore code for uploading and it is working fine but now i want to get a seperately each column values from that large file ,i used the following code.

/// For file uploading i have used the following code

String saveFile = "";
contentType = request.getContentType();
if ((contentType != null)
&& (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request
.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead,
formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
saveFile = file.substring(file.indexOf("filename=\"") + 10);
//System.out.println("saved file is " + saveFile);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//System.out.println("saved file is " + saveFile);
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,
saveFile.indexOf("\""));
//System.out.println("saved file is " + saveFile);
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,
contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
startPos = ((file.substring(0, pos)).getBytes()).length;
endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
saveFile = "E:/workspace/harini/MassEmailSending/SmallProjectOnMassEmailSending/WebContent/file/" + saveFile;
System.out.println("saved file is "+saveFile);
File f = new File(saveFile);
FileOutputStream fileOut = new FileOutputStream(f);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
}


/// For reading a excel file i used the following code with apache poi

if (filename != null && !filename.equals("")) {//1
try {//2
/*int l=0;
for(int i=0;i<arlMessage.size();i++){
String str = (String) arlMessage.get(i);
String s=str.replace("~","");
int intValue=Integer.parseInt(s);
intValue-=1;*/

FileInputStream fs = new FileInputStream(strFileAttachment);
Attachment = strFileAttachment.split("\n");
HSSFWorkbook wb = new HSSFWorkbook(fs);
for (int k = 0; k < wb.getNumberOfSheets(); k++) {//3
HSSFSheet sheet = wb.getSheetAt(k);
int rows = sheet.getPhysicalNumberOfRows();
for (int r = 1; r < rows; r++) {//4
HSSFRow row = sheet.getRow(r);
if (row != null) {//5
int cells = row.getPhysicalNumberOfCells();

// int l=0;
HSSFCell cell = row.getCell(0);
if (cell != null) {//6
//String value = null;
switch (cell.getCellType()) {//7
case HSSFCell.CELL_TYPE_FORMULA:
value = "FORMULA ";
break;

case HSSFCell.CELL_TYPE_NUMERIC:
value = "" + cell.getNumericCellValue();
break;

case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;

default:
}//7
%><%--=value--%><input type="hidden" name="email" value="<%=value%>">


Using this code i am getting nothing values if i upload a large file ,if i upload a small file it works fine .Where my code going wrong i am not getting so please help me sir.


Thanks and Regards
Harini Veerapur.

Advertisement
View Answers

Related Tutorials/Questions & Answers:
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values
Excel File data upload into postgresql database in struts 1.x
Excel File data upload into postgresql database in struts 1.x  Dear members please explain how Excel Files data upload into postgresql database in struts 1.x
Advertisements
How to Split a large XML file using java?
How to Split a large XML file using java?  How can we split a 500MB Xml file?I know how to split xml file after reading the entire document in a file.Here we cannot load the entire file as it is a large file
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
How to upload file on FTP Server
How to upload file on FTP Server  In my application there is a requirement of uploading the file on FTP server. How to upload file on FTP Server... is good and can be used in Java applications. Read FTP File Upload in Java for more
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
Upload and Download Large files in jsp
Upload and Download Large files in jsp  I am not able to download large files (>200mb) from any server. I need a code to download and upload large files (atleast 4 gb) to a server using jsp page
How to Increase Upload File Size Limit in php
How to Increase Upload File Size Limit in php  Increase Upload File.... But the default file upload size settings restrict you to upload large files. PHP.... This setting also affects file upload. To upload large files, this value must
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
upload a file into database and progrm should support excel and text and csv file formats
upload a file into database and progrm should support excel and text and csv file formats  Hai all, I need a program to upload a file into database table... and the program should support .excel ,.txt ,.csv file formats. can
how to upload a file - JSP-Servlet
how to upload a file  Dear sir, Give me some code...: Display file upload form to the user UPLOAD THE FILE   Choose the file To Upload:   2
How to read a large text file line by line in java?
How to read a large text file line by line in java?  I have been assigned a work to read big text file and extract the data and save into database... you kind advice and let's know how to read a large text file line by line in java
How to upload file using JSP?
How to upload file using JSP?   Hi all, I m the beginner in JSP, I want to upload file on server in specific folder.   1)page.jsp... file upload form to the user</TITLE></HEAD> <
How to insert rows from Excel spreadsheet into database by browsing the excel file?
the excel file using file browsing dialogue through form in JSP. How can i select...How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i
Java MappedByteBuffer example, How to create a large size file in java.
Java MappedByteBuffer example, How to create a large file in java. In this tutorial, you will see how to create a large file with the help...;} } Output C:\>java CreateFile File
how to upload file using FTP in java
how to upload file using FTP in java  hai, i want to upload file using FTP in java Webservices.. Tel me some Articles Regards Asha
how to display the excel file content in the jsp
how to display the excel file content in the jsp  How to present the content of the newly created excel file in the following jsp to the web browser...="application/vnd.ms-excel" %> <%@ page import="java.io.*" %> <
how to display the output of the newly created excel file
how to display the output of the newly created excel file  the following program will create the test.xlsx file, how can i display the content of the test.xlsx file in the web browser? thanks, %@ page import
how to display the excel file in the web browser.
how to display the excel file in the web browser.  > %@ page.../vnd.ms-excel" > %> <%@ page import="java.io.*" %> <% >... FileOutputStream > ("c:\\excel\\aqtemplate.xlsx"); > wb.write
How to delete excel file records using Store Procedure?
How to delete excel file records using Store Procedure?  Hi.. I have created one Excel file through stored procedure.Now I want to delete records or delete excel file. Thanks
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi All, I m the beginner in JSP and I want to upload the file and store that file... form like Emp name, Emp id, city, address and one employee profile image(upload
How to upload and save a file in a folder - Java Beginners
How to upload and save a file in a folder  Hi How to upload and save a file in a folder? for example Agreement.jsp File: So when user browses the file and enters the submit button the respective file should
Struts upload file - Framework
Struts upload file  Hi, I have upload a file from struts application.I am able to get the file name using getFileName() i created excel file and send to file upload struts..how to get the sheets and data in that sheets
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java    How to export data from html file to excel sheet by using java
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link an excel file with the application software using java swing
How to link an excel file with the application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
How to link a excel file with a application software using java swing
How to link a excel file with a application software using java swing  I have to link an excel file with a application software which I am developing.The excel file will contain questionnaire for surveys.I have this code which
File Upload in Struts.
File Upload in Struts.  How to do File Upload in Struts
how to upload a file of apk format in a folder from servlet
how to upload a file of apk format in a folder from servlet  How to upload a file of apk format to a folder from servlet, i am trying to do, its getting uploaded as .zip file and not apk file
splitting large xml file. - XML
splitting large xml file.  Hi, I have a large xml file(1G) and a schema (XSD) i need to split this xml to small xml files (~20M) that will be valid by the schema
 

 

 

DMCA.com