Write to Excel from VB.NET web app

Hi everyone!!

I am using this code to write a new excel spreadsheet from VB.NET and populate it with values.However I keep getting the error "cannot create active x component."I am thinking it has something to do with security features but Im just wondering if anyone has any ideas!!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sConn As String
sConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\temp\NewExcel.xls; Extended Properties=Excel 8.0;"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConn)
Dim objCmd As New System.Data.OleDb.OleDbCommand
objCmd.Connection = objConn
objCmd.CommandText = "Insert into [Sheet1$] (TitleOne, TitleTwo, TitleThree, TitleFour, TitleFive) values ('This', 'is', 'just', 'some', 'text')"
End Sub

Sub MakeNewFile()
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
oSheet.Range("A1").value = "TitleOne"
oSheet.Range("B1").value = "TitleTwo"
oSheet.Range("C1").value = "TitleThree"
oSheet.Range("D1").value = "TitleFour"
oSheet.Range("E1").value = "TitleFive"
oSheet = Nothing
oBook = Nothing
oExcel = Nothing
End Sub
Thank you!
Julie :)
2/16/2005 12:28:04 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 5


Similar Artilces:

Run Vb.net Web app using Web Harpoon
Does anyone know what Begin Tag and End Tag to use to run a VB.Net web App in Web Harpoon? We are experiencing errors trying to run the app. Error --> The state information is invalid for this page and might be corrupted Thanks,   Erik...

Reading Checkboxes in Excel from VB.NET Web App
Hi, I am currently developing a program to read data from an Excel spreadsheet.My problem is where I have implemented checkboxes in the spreadsheet.I need to be able to read whether or not the user has checked the box from the VB.NET web app. Would anyone have any good links regarding this!? Thank you! Julie...

convert java web app 2 .NET web app
Hi, i am able to convert java console app to .NET console app.but i am unable to convert java web based application to .NET web based application. can u give me some idea as to how to convert that. Thanks in advance,nizam. I believe the technical phrase is.. rtfm?  lol.  you're going to have to do it the hard way.  JSP operates on a different theory of web development than asp.net/asp.net 2.0Kay LeeMySpace.com - http://www.myspace.com/kragieInfrastructure GroupMySpace.com- Code to live, but Live to code. Try these two links for sample code and free book from Microsoft, ...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Converting Web Site from Vb.Net 2003 to Vb.Net 2005
I have a web site in vb.net 2003 that I what to convert to vb.net 2005. I open my web site in the visual studio 2005 by Local IIS option. I follow the steps of the visual studio conversion wizard.In the conversion report I received the following warning 'Referencepath' settings have not been converted.  Can anyone tell what I have to do to make this warning disappear? Best regards,Sérgio 'Referencepath'  is a property you can set with with VS2003 project file, sothat when ever you to do Add reference this path is serached for class libraries.  We do not  have that ...

VB.NET Data Grid, windows app to web app
Is it possible to make a Web Application Data Grid element with identical functionality as a Windows Application Data Grid? When I run the code as a windows application, it allows me to make direct edits of each database record through the data grid. When I run the code through a browser, however, it only displays the records. This is the code:Any suggestions? Inherits System.Web.UI.Page Dim connstr As String = "data source=SERVER;initial catalog=DB;user id=USER;password=PASSWORD;" Dim sqlStr As String = "SELECT * FROM Users" Dim dt As New DataTable Private Sub btnLoad_Click(B...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Both C# ASPX pages and VB.NET ASPX in single VB.NET Web Applcation Template
Hi.. Is it possible to have both c# pages and VB pages in same Webapplication, what i chose is VB.NET Web application Template. With Thanks, Jaya.... I don't see why you couldn't, but for the sake of consistency I don't know why you would want to do this. When you choose a C# or VB.NET application template(I'm assuming you're using VS or WebMatrix), it simply creates a .aspx file that includes a page directive that specifies the page language. If you created a C# template but want to use VB.Net instead, you need to go from: <%@ Page Language="C#" .... to...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Convert VB.Net Web Site to Web Application Project
I am working with Visual Studio Pro SP1 and had some problems converting an old VB.Net web site into a VB.Net Web Application Project.  I followed the advice offered here ( http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx ), but ran into a...

Convert VB.Net Web Site to Web Application Project
 I am working with Visual Studio Pro SP1 and had some problems converting an old VB.Net web site into a VB.Net Web Application Project.  I followed the advice offered here ( http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx ), but ran into a few kinks when using the process on a VB project.  The Problem:After creating a new Web Application Project, copying in the old files, and running the "Convert to Web Application Project" process, the site would no longer build.  Any classes stored in the "Old_App_Code" folder (previously named...

Web resources about - Write to Excel from VB.NET web app - asp.net.web-forms

Islamic State broadcast says followers of the group carried out California attacks
Islamic State said in an online radio broadcast on Saturday that two followers of the Islamist militant group had carried out Wednesday's attack ...

Will Janet Yellen Sabotage Hillary Clinton?
A 211,000 jobs increase for November will finally push the Fed over the line and into a quarter-of-a-point rate hike later this month. The question ...

Why the U.S. should cut corporate tax rates
Big controversies often arise from big numbers, and on the surface the cost in U.S. tax revenue from the corporate tax avoidance scheme known ...

Scott Weiland Dies At 48, Bandmate Arrested For Cocaine Found On Tour Bus
The music world was rocked by the news that former Stone Temple Pilots front-man, Scott Weiland, was found dead on December 3, in Bloomington, ...

Here’s Why Donald Trump’s December Poll Numbers Matter
Here’s some good news for Donald Trump fans: History is now on his side. For months, members of the Republican Establishment have dismissed ...

Samsung agrees to pay Apple $548 million in settlement
Samsung has been fighting Apple in court for years, but it sounds like it's getting near to letting it all go. The South Korean electronics maker ...

US Supreme Court to hear Puerto Rico debt appeal case
The US Supreme Court agreed to consider Puerto Rico's appeal of a ruling forbidding its use of a US law that would allow it to declare bankruptcy ...

Texas backs down from effort to block Syrian refugees
Washington Post Texas backs down from effort to block Syrian refugees Miami Herald Texas stopped trying Friday to block Syrian refugees from ...

Battling climate change—with worms
Nicolas Denieul plants his spade in the ground and turns over a clod of soil to reveal a mass of earthworms seething around plant roots—fat ones ...

Demi Lovato Reacts to the Death of Co-Star Tiffany Thornton's Husband
Demi Lovato is speaking out about the death of Chris Carney , who tragically passed away in a car accident early Friday morning (December 4). ...

Resources last updated: 12/5/2015 10:58:25 AM