.NETGURU
Office XP Web Components on ASP.NET Pages
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-msoffice' list.


Jamse Yang
-- Moved from [aspngfreeforall] to [ngfx-msoffice] by Tony Stark <Click here to reveal e-mail address> --

Hi list

could any one guide me to a good tutorial on how you can use Office XP Web
Components on ASP.NET pages?

thank you

Reply to this message...
 
    
Scott Hutchinson
Here is some information I recently posted on a Microsoft newsgroup that
might be helpful to you. It describes a procedure for binding a Spreadsheet
control to a database and programatically or manually changing the
connection string and/or query string:

I hope you realize that the spreadsheet control is a client-side control
that requires the user to run IE and to have a license for Microsoft Office.
This might be ok for an Intranet application. For an Internet application,
you would probably want to use the server-side ASP .NET DataGrid control
instead. I came up with a solution that works, but it's not the one I was
expecting.

I thought the solution would be to add a reference to "Microsoft Office XP
Web Components" (if you added the Microsoft Office 10.0 Spreadsheet control
to the Web Form). This actually added references to 5 assemblies (wrapping 5
COM DLLs). The namespace that we needed is "OWC10" for Office Web Components
10.0. I also added an "ID" attribute to the OBJECT tag in the HTML source of
the .ASPX file, which would probably allow you to write client-side script
for the spreadsheet. But I doubt if you want to set the connection string in
client-side script, since the user could use "View Source" to read it. There
might be a way to script it on the server, but I couldn't find it, so I came
up with the following alternative solution.

1. Right-click the project in Solution Explorer and choose Add...Add New
Item...XML File, and name the file "Data.xml" (or whatever you wish). This
should create and open a blank XML file in your application folder.
2. In the HTML source of the .ASPX file, copy the value of the "XMLData"
parameter inside the spreadsheet OBJECT element and paste it into the open
Data.xml file.
3. Replace all occurrences of with an empty string to remove
them, then save the Data.xml file.
4. In the property pages for the spreadsheet control, on the Import tab, set
"Data Type" = XML, set "URL" = "Data.xml", and check the "Refresh Data from
URL at run time" checkbox, which will add an "XMLURL" parameter inside the
spreadsheet OBJECT element.
5. Now you should be able to manually edit the ConnectionString and/or
CommandText elements in the Data.xml file to change those parameters without
having to re-compile the application. Or you can programatically modify the
parameters at run-time using code like that shown below in a Page_Load event
procedure.
6. For the code to run, you must grant the ASPNET user read and write access
to the Data.xml file in Windows Explorer.
7. To prevent the user from downloading Data.xml by typing its URL in the
browser location, I attempted to change the file name to "Data.config", but
the control failed to work properly without the .xml file extension. So I
tried adding an <httpHandlers> section to the application's web.config file,
but it had no effect. At least the user must guess the name of the file in
order to navigate to it.

Dim szXMLFilePath As String = MapPath("Data.xml")

Dim xmlDoc As System.Xml.XmlDataDocument = New System.Xml.XmlDataDocument()

Dim myDataSet As DataSet = xmlDoc.DataSet

Dim aszEmpty() As String

myDataSet.InferXmlSchema(szXMLFilePath, aszEmpty)

xmlDoc.Load(szXMLFilePath)

With myDataSet.Tables("DataSource").Rows(0)

''' The DataSource option in the connection string is the name of the
database server. "DataSource=." refers to the local server.

.Item("ConnectionString") = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data
Source=.;PASSWORD=;"

.Item("CommandText") = "SELECT * FROM Products WHERE ProductName LIKE 'C%'"

End With ''' myDataSet.Tables("DataSource").Rows(0)

xmlDoc.Save(szXMLFilePath)

Scott Hutchinson
Click here to reveal e-mail address
(to contact me, remove all dots left of @)

"A Jao" <Click here to reveal e-mail address> wrote in message
news:276b01c20038$8eedc170$9de62ecf@tkmsftngxs01...
[Original message clipped]

Scott Hutchinson
Click here to reveal e-mail address
(to contact me, remove all dots left of @)

"Jamse Yang" <Click here to reveal e-mail address> wrote in message
news:655285@ngfx-msoffice...
[Original message clipped]

Reply to this message...
 
 
System.Data.DataSet
System.Web.UI.WebControls.DataGrid
System.Windows.Forms.DataGrid
System.Xml.XmlDataDocument




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification