473,513 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not able to write in Excel from asp.net

18 New Member
hi all

i am trying to read and write data in Excel file from asp.net

I am able to read the data of particular cell, but i am not able to write in Excel file.

I am getting error: ComException: Document not saved;

Any help would be appreciated.
thanx.

*****************************************My Code***********************************
Dim MyExcel As Microsoft.Office.Interop.Excel.Application
Dim MyWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim MySheet As Microsoft.Office.Interop.Excel.Worksheet
Dim MyCell As Microsoft.Office.Interop.Excel.Range

MyExcel = New Microsoft.Office.Interop.Excel.Application
MyExcel.Workbooks.Open("C:\Inetpub\wwwroot\AddNewP romotion\Excel1.xls", , False)
MyWorkbook = MyExcel.Application.ActiveWorkbook
MySheet = MyWorkbook.ActiveSheet
Label1.Text() = MySheet.Cells.Item(1, 1).value

MySheet.Cells.Item(2, 2).value = "Example"

MyExcel.ActiveWorkbook.SaveAs("C:\Inetpub\wwwroot\ AddNewPromotion\Excel2.xls")
MyExcel.ActiveWorkbook.Close()
MyExcel = Nothing
MyWorkbook = Nothing
MySheet = Nothing

******************************************End***** ********************************
Oct 25 '06 #1
0 1789

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1975
by: Randy | last post by:
Hello, I'm trying to figure out how to do the above. I'm using a snippet of code I found on the net (see below). My problem is when I hit the line (oXL = new Excel.Application();) I get an exception which says..."Access is Denied". Does anyone know what I'm doing wrong? string strFileName = null; string fileName = "Hockey";...
0
2037
by: Katie | last post by:
Our ASP.NET app produces a page in excel format using Response.ContentType = "application/vnd.ms-excel" Response.Write(strExcel) (where strExcel is a tab and carriage return delimited string) When this page is sent to the browser (IE6SP1), the excel active X control opens up within IE6. Then if you do a File|Save As, you can save the...
1
3501
by: sweety | last post by:
Hi, Very Urgent... I Need to write a structure of data which is in "C" to excel file(*.xls). So, using C/VC++ how i can create a Excel file and how i can write a data into the respective cell at run time.
4
7269
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel file being created, it will be sent out via email to the list of recipients. I run the script on my notebook (also developed on th same machine) it...
0
3648
by: vinidimple | last post by:
Hi i have a serious problem while i was working in Excel.I want to fetch columns from an excel worksheet and i need to compare it with an sql querry fields,so i tried to open an excle worksheet first.. Unfortunately my code was throwing error like
2
1589
by: raj2007 | last post by:
Hi, I am not able to see certain columns from the excel sheet when I am trying to load the excel sheet data in to a sql server using SQL server 2000 DTS. Please let me know if there is any setting or any way by which I would be able to read the data from the excel file regardless of its format. Please help me resolve this. Thanks!!
0
1242
by: newUser1234 | last post by:
I'm trying to read and write from an excel file using this method..My application can read the excel file without problems but doesn't write anything to the file i want it to write. I've also tried adding a '.Value' to the end, it doesn't seem to help. I have closed the file in the end as well.. Any Suggestions would be very helpful ...
6
12339
by: =?Utf-8?B?LnBhdWwu?= | last post by:
how can i write to an excel .xls file using odbc? i've read in several places that its possible but i can't find an example. i have managed to read an excel file using odbc
8
28315
blazedaces
by: blazedaces | last post by:
So I have a program below which writes an excel file with multiple sheets based on inputs of sheet names, data, cell types, etc. It uses Apache POI, which is currently the only thing I found (correct me if I'm wrong about this) that can write excel 2007 files. The program works. I've tested it out on very small files (I will include the...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7125
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.