473,588 Members | 2,582 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.Offic e.Interop.Excel .Application
Dim MyWorkbook As Microsoft.Offic e.Interop.Excel .Workbook
Dim MySheet As Microsoft.Offic e.Interop.Excel .Worksheet
Dim MyCell As Microsoft.Offic e.Interop.Excel .Range

MyExcel = New Microsoft.Offic e.Interop.Excel .Application
MyExcel.Workboo ks.Open("C:\Ine tpub\wwwroot\Ad dNewPromotion\E xcel1.xls", , False)
MyWorkbook = MyExcel.Applica tion.ActiveWork book
MySheet = MyWorkbook.Acti veSheet
Label1.Text() = MySheet.Cells.I tem(1, 1).value

MySheet.Cells.I tem(2, 2).value = "Example"

MyExcel.ActiveW orkbook.SaveAs( "C:\Inetpub\www root\AddNewProm otion\Excel2.xl s")
MyExcel.ActiveW orkbook.Close()
MyExcel = Nothing
MyWorkbook = Nothing
MySheet = Nothing

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

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

Similar topics

2
1986
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"; Excel.Application oXL; Excel._Workbook oWB;
0
2052
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 file locally.
1
3504
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
7274
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 works fine. However, when I copy all the programs into the server which running on Windows 2000...
0
3662
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
1597
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
1244
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 Dim excel_app As New Excel.Application Dim xlWkBk As Excel.Workbook Dim xlSheet As...
6
12358
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
28344
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 commented out main method that you can use to test this out yourself if you'd like, that is assuming you...
0
7927
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7981
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6632
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5396
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3846
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.