Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Open XML string in Excel using C#

Hello,

I am using the code below to programmatically create an .xls file:
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);

I have an XML string of data that I'd like to just "shove" into the .xls
then open Excel. The XML string is a result of an SQL query. The User will
then use Excel view and manipulate the data.
I've found no API documentation to do this en masse and not cell by cell.

Thanks in advance,

Stefani



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Open XML string in Excel using C#


"Stefani" wrote in message
...
Hello,

I am using the code below to programmatically create an .xls file:
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);

I have an XML string of data that I'd like to just "shove" into the .xls
then open Excel. The XML string is a result of an SQL query. The User

will
then use Excel view and manipulate the data.
I've found no API documentation to do this en masse and not cell by cell.

Thanks in advance,

Stefani


Save the xml string to a file with an xml extension. Excel can open xml
files. I think you need at least Excel 2002.

/Fredrik


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Open XML string in Excel using C#

Fredrik,

I don't have that option. I need to open the XML string in memory in Excel
then give User option to save.

Any ideas?

Thanks,

Stefani

"Fredrik Wahlgren" wrote in message
...

Save the xml string to a file with an xml extension. Excel can open xml
files. I think you need at least Excel 2002.

/Fredrik



"Stefani" wrote in message
...
Hello,

I am using the code below to programmatically create an .xls file:
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);

I have an XML string of data that I'd like to just "shove" into the .xls
then open Excel. The XML string is a result of an SQL query. The User

will
then use Excel view and manipulate the data.
I've found no API documentation to do this en masse and not cell by cell.

Thanks in advance,

Stefani







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Open XML string in Excel using C#


"Stefani" wrote in message
...
Fredrik,

I don't have that option. I need to open the XML string in memory in

Excel
then give User option to save.

Any ideas?

Thanks,

Stefani


Why not? Create a temporary file which you open from Excel and then delete
the file.

7Fredrik


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Open XML string in Excel using C#

For this particular application and in this situation, we do not want to
write a temp file to the client's desktop. That's why I'd like to find a
way to create a workbook in memory and populate with the XML string.

Thanks,

Stefani



"Fredrik Wahlgren" wrote in message
...


Why not? Create a temporary file which you open from Excel and then delete
the file.

7Fredrik




"Stefani" wrote in message
...
Fredrik,

I don't have that option. I need to open the XML string in memory in

Excel
then give User option to save.

Any ideas?

Thanks,

Stefani








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Open XML string in Excel using C#

Hi

Based on my understanding, you want to transfer the xml data from database
to excel workbook.
I think you may also try to transfer the SQL data to excel workbook
directly.

Here are two links for your reference.

HOW TO: Transfer Data to an Excel Workbook by Using Visual C# .NET (306023)
http://support.microsoft.com/default...B;EN-US;306023

How To Transfer XML Data to Microsoft Excel 2002 by Using Visual C# .NET
(307029)
http://support.microsoft.com/default...B;EN-US;307029

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Open XML string in Excel using C#

Hi,

I've seen both documentation references before and neither address my
situation. I'm starting to get very frustrated with Mr. Gates. Why is
complete documentation so difficult to find???

Any who...Here's what I'm trying to do:

1) First I'd like a way to programmatically create a workbook then stuff an
XML string into it then open the workbook in XML. What I've found is only a
way to create a workbook then cell by cell populate it then open it. The
other option to save the XML string in a .xml file first then open that
saved file in Excel is not really a great option for me. So if you can
point me to some documentation that might show me how do this it would be
great.

2) Now if there is no way to do #1 and I have to save the XML in a file
first then open in Excel, I have another question. When you open an .xml
with Excel, you are prompted with: "Open XML - as XML list, as workbook, use
the XML Source task pane?" What I'd like to do is programmatically tell
Excel to open the file "as XML list". Excel should open XML source creating
a default schema since one wasn't specified.

The method I'm using to open the .xml file is

excelApp.Workbooks.OpenXML(fileName, Type.Missing);

The second parameter is a Stylesheet. Since the XML is data based on a SQL
query, I don't know enough in advance to provide a matching Stylesheet. I
was hoping that when Excel opens the User would be provided the same prompt
as if she opened the file directly with Excel.

I was also hoping that .OpenXML would have overload where how the file is
open could be provided.


If you could point me to any documentation you'd be a lifesaver.

Thanks,

Stefani



""Peter Huang" [MSFT]" wrote in message
...
Hi

Based on my understanding, you want to transfer the xml data from database
to excel workbook.
I think you may also try to transfer the SQL data to excel workbook
directly.

Here are two links for your reference.

HOW TO: Transfer Data to an Excel Workbook by Using Visual C# .NET
(306023)
http://support.microsoft.com/default...B;EN-US;306023

How To Transfer XML Data to Microsoft Excel 2002 by Using Visual C# .NET
(307029)
http://support.microsoft.com/default...B;EN-US;307029

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Open XML string in Excel using C#


"Stefani" wrote in message
...
Hi,

I've seen both documentation references before and neither address my
situation. I'm starting to get very frustrated with Mr. Gates. Why is
complete documentation so difficult to find???

Any who...Here's what I'm trying to do:

1) First I'd like a way to programmatically create a workbook then stuff

an
XML string into it then open the workbook in XML. What I've found is only

a
way to create a workbook then cell by cell populate it then open it. The
other option to save the XML string in a .xml file first then open that
saved file in Excel is not really a great option for me. So if you can
point me to some documentation that might show me how do this it would be
great.

2) Now if there is no way to do #1 and I have to save the XML in a file
first then open in Excel, I have another question. When you open an .xml
with Excel, you are prompted with: "Open XML - as XML list, as workbook,

use
the XML Source task pane?" What I'd like to do is programmatically tell
Excel to open the file "as XML list". Excel should open XML source

creating
a default schema since one wasn't specified.

The method I'm using to open the .xml file is

excelApp.Workbooks.OpenXML(fileName, Type.Missing);

The second parameter is a Stylesheet. Since the XML is data based on a

SQL
query, I don't know enough in advance to provide a matching Stylesheet. I
was hoping that when Excel opens the User would be provided the same

prompt
as if she opened the file directly with Excel.

I was also hoping that .OpenXML would have overload where how the file is
open could be provided.


If you could point me to any documentation you'd be a lifesaver.

Thanks,

Stefani


According to this article, you should omit the the value for the second
parameter. I'm not sure you can do that, you use some .NET language, right?
http://support.microsoft.com/default...b;en-us;307230

/Fredrik


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Open XML string in Excel using C#

Hi

I think you may try to take a look at the link below.
OpenXML Method
http://msdn.microsoft.com/library/de...us/vbaxl11/htm
l/xlmthOpenXML_HV03080763.asp

Note XML features, except for saving files in the XML Spreadsheet format,
are available only in Microsoft Office Professional Edition 2003 and
Microsoft Office Excel 2003.

In office 2003, we have a LoadOption parameter for OpenXML method.
xlXmlLoadPromptUser Prompts the user and lets them choose the Import method.
Here is a code snippet for your reference.
Excel.Application exApp = new Excel.ApplicationClass();
object oMissing = System.Reflection.Missing.Value;

",oMissing,Ex cel.XlXmlLoadOption.xlXmlL
oadPromptUser);

Please perform the test and let me know the result.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
string assistance to open workbook via macro fishy Excel Discussion (Misc queries) 2 March 5th 08 10:56 AM
EXCEL wont open from Explorer, must open EXCEL then find file wludwick Excel Discussion (Misc queries) 4 September 7th 06 08:06 PM
Open Books with VBA based on certain string [email protected] Excel Discussion (Misc queries) 3 September 6th 06 11:35 PM
Macro to open most recent file with a particular filename string kwiklearner Excel Discussion (Misc queries) 1 August 23rd 06 01:24 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


All times are GMT +1. The time now is 09:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"