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 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.
View Answers
Related Tutorials/Questions & Answers:
How to upload a large excel file - JSP-ServletHow 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
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 Increase Upload File Size Limit in phpHow 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 upload file on FTP ServerHow 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 upload and download file in hadoop?How to
upload and download
file in hadoop? Hi,
I am trying to learn to
upload the
file on the Hadoop HDFS and then download the same
file for learning the process.
How to
upload and download
file in hadoop?
What
Upload and Download Large files in jspUpload 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 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 display the excel file content in the jsphow 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 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 do I read a large file quickly in Java?How do I read a
large file quickly in Java? Hi,
I my project I have... in 1-2 GB in size. What is the best way to read the
file efficiently?
How do I read a
large file quickly in Java?
Thanks
Hi,
You can't read the whole
Struts upload file - FrameworkStruts
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
File UploadFile Upload when i execute the image
upload to mysql database it shows an exception that
file path cannot be found
How to Read Excel file Using Java How to Read
Excel file
In this section,you will learn
how to read
excel file... and every cell and stored the
excel file values into the
vector.This Vector data is then used to display
file values on the console.
Here is the code
splitting large xml file. - XMLsplitting
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
How to convert excel file int xml format in javaHow to convert
excel file int xml format in java
How to read
excel file(xls) which is stored in any directory(D://) and convert it into xml format in java and place in any directory(E://).Can any body provide the code
jsp upload file to serverjsp
upload file to server
How to create and
upload file to server in JSP?
Find the given example that explains
how to
upload single and multiple
file on server using JSP
file uploadfile upload
how to recieve the uploaded
file on the next jsp page for modification if its uploaded to the previous page using a from
File UploadFile Upload Hi
I need script / string in PHP where I uploaded the
file in html frontend and it should sent the uploaded
file as attachment to my email address