473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ASP.Net C# Excel Upload Question

Good Day All,

Sorry if I am posting in the wrong forum, hopefully someone will be able to
push me in the right direction. What I am trying to accomplish is allowing a
client to upload an Excel file and then I need to access the Excel file
without saving the file directly to the server. What I am eventually going to
do is save the Excel data into a database. Here is a sample of what I am
trying to do, and I may be way off track here.

if ( filMetricFile.PostedFile != null )
{
// Get a reference to PostedFile object
HttpPostedFile _metricFile = filMetricFile.PostedFile;

// Get size of uploaded file
int nFileLen = _metricFile.ContentLength;

// make sure the size of the file is > 0
if( nFileLen > 0 )
{
// Allocate a buffer for reading of the file
byte[] _metricData = new byte[nFileLen];
// Read uploaded file from the Stream
_metricFile.InputStream.Read(_metricData, 0, nFileLen);

OleDbConnection ExcelConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ _metricFile + ";Extended Properties=Excel 8.0;");

ExcelConnection.Open();

//Do something with the ExcelConnection
}
}

And of course I am sure you can see I am missing something. When I try the
ExcelConnection.Open() I will get a an error stating that the object is read
only.

So I’m not sure if what I am doing is even possible, but any help would be
greatly appreciated. I just want to process the Excel file while in memory
and not have to save the file directly to the server first.

Thanks,
Jake

Nov 16 '05 #1
1 2799
Jake:

I don't believe there is going to be an easy way to do this. Excel
runs as a separate process, and you can't just pass it a pointer or a
reference to a block of memory sitting in the web application.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 19 Nov 2004 11:35:20 -0800, "Jake"
<Ja**@discussions.microsoft.com> wrote:
Good Day All,

Sorry if I am posting in the wrong forum, hopefully someone will be able to
push me in the right direction. What I am trying to accomplish is allowing a
client to upload an Excel file and then I need to access the Excel file
without saving the file directly to the server. What I am eventually going to
do is save the Excel data into a database. Here is a sample of what I am
trying to do, and I may be way off track here.

if ( filMetricFile.PostedFile != null )
{
// Get a reference to PostedFile object
HttpPostedFile _metricFile = filMetricFile.PostedFile;

// Get size of uploaded file
int nFileLen = _metricFile.ContentLength;

// make sure the size of the file is > 0
if( nFileLen > 0 )
{
// Allocate a buffer for reading of the file
byte[] _metricData = new byte[nFileLen];
// Read uploaded file from the Stream
_metricFile.InputStream.Read(_metricData, 0, nFileLen);

OleDbConnection ExcelConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ _metricFile + ";Extended Properties=Excel 8.0;");

ExcelConnection.Open();

//Do something with the ExcelConnection
}
}

And of course I am sure you can see I am missing something. When I try the
ExcelConnection.Open() I will get a an error stating that the object is read
only.

So I’m not sure if what I am doing is even possible, but any help would be
greatly appreciated. I just want to process the Excel file while in memory
and not have to save the file directly to the server first.

Thanks,
Jake


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vikram | last post by:
Hi, Given below is my task. An user can open the xls file from my website (loaded on the top frame). After filling the Excel, he can click a send button at the bottom frame. By clicking the...
3
by: Prakash | last post by:
Hi, We face problems uploading excel (with macros) documents using HTML File Upload. The file contents are corrupted while viewing the same. However, we are able to upload excel (w/o. macros)...
3
by: Rik Moed | last post by:
Hi, I am having a problem with Excel 2003 worksheets when I upload them using the HtmlIputFile. After the upload, I start to download the worksheet and it appears to be currupt. I recieve the...
1
by: Daniel | last post by:
Hi, can u explain to me what is the path need to use in order to upload and download the file based on below solution: 1.Set up a folder that both the web app and SQL server can get to. 2.Do a...
6
by: Daniel | last post by:
Hi all, Can i open and edit the excel sheet on web page after downloading? After editing, i close the web page and the excel file auto upload to the server. Is it possible? I really struggling...
1
by: vic pahilan | last post by:
hi, pls need help. I need to upload excel field to sql server field. the user will choose excel file then i will show the fields inside that excel file then copy it into sql server field. I...
3
by: c676228 | last post by:
Hi everyone, I will develop a program to enroll a group of people on-line. Since we don't have number limitation for the people in the group. I am wondering if there is any company allow people...
1
by: =?Utf-8?B?TGFtaXM=?= | last post by:
HI, I am doing an aspx application and need to let my users be able to edit the information in my database by the page. My first Idea was to let them export the information to an excel file at...
5
by: priyammaheshwari | last post by:
Hi all, I have a MS Access database in which requests made by people is stored,but a coulmn for cost is left empty which is suppose to be populated by the administrator.Now the administrator wants...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.