473,769 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible to build up an Excel document programmaticall y?

I understand that the new versions of MS
Word, MS Excel etc. allow for creation of
a document using XML tags (the technique
or format is called OOXML, i think).

I imagine that the idea behind such
creation resembles principally the way of
creating a GUI using WPF, where one can
mark up what parts of the text mass
should carry this or that format etc.

Is it at all true? I've been googling and
experimenting a bit lately but i wasn't
especially successfull... :(

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 11 '08 #1
8 3233
On Sat, 11 Oct 2008 00:53:52 -0700, K Viltersten <tm**@vilterste n.com>
wrote:
I understand that the new versions of MS Word, MS Excel etc. allow for
creation of a document using XML tags (the technique
or format is called OOXML, i think).

I imagine that the idea behind such creation resembles principally the
way of
creating a GUI using WPF, where one can mark up what parts of the text
mass should carry this or that format etc. [...]
IMHO, it resembles WPF only inasmuch as they both are using XML. One
obvious different being that the Office formats describe a static document
(for the most part), whereas WPF has some things in it that provide
connections between a declared GUI and code that works with that.

As far as writing an Office document explicitly using XML goes, sure...I
suppose you could do that. I don't recall whether Microsoft's actually
published their new XML-based format yet, but they probably have. As long
as you comply with the format, you're fine.

But the format is undoubtedly fairly complex. If you have to create a
document without having Office installed, that might be the only viable
approach. But otherwise, you would probably find yourself better off
actually using Office to create the document, through the Office interop
classes.

Pete
Oct 11 '08 #2
>I understand that the new versions of MS Word, MS Excel etc. allow for
>creation of a document using XML tags (the technique
or format is called OOXML, i think).
<snip>
But the format is undoubtedly fairly complex. If you have to create a
document without having Office installed, that might be the only viable
approach. But otherwise, you would probably find yourself better off
actually using Office to create the document, through the Office interop
classes.
The document will be created on a server with no Office
installed (at least not what i can guarantee). The nice part is
that it won't be a very complicated document, most often,
only some data put together, so it won't be that much work.

What i don't really see is how to get started. Suppose i'd like
to create a document with a blue text saying "hello" in cell B3.
How can i do that? I've tried to save sucha document from
Office but i didn't really got an XML-structure in it.

Some pointers or a very short example would be great.
Thanks.

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 11 '08 #3
K Viltersten wrote:
I understand that the new versions of MS Word, MS Excel etc. allow for
creation of a document using XML tags (the technique
or format is called OOXML, i think).

I imagine that the idea behind such creation resembles principally the
way of
creating a GUI using WPF, where one can mark up what parts of the text
mass should carry this or that format etc.
Yes and no. The underlying techniques resemble each other but the formats
really don't. You'd need a serious conversion step to get WPF-to-OOXML.
Is it at all true? I've been googling and
experimenting a bit lately but i wasn't
especially successfull... :(
Producing an Excel document programmaticall y isn't hard, because, as you've
pointed out, it accepts XML. Actually, Excel even accepts *HTML*, so you can
use a GridView with adjusted rendering to produce a quick and dirty Excel
sheet. See http://aspalliance.com/771

This is basically your idea, but using different technologies. It can be
made more complex if you want "true" Excel sheets (with formulas and such)
using a ControlAdapter and knowledge of OOXML, but if you're going this far
you can probably directly output OOXML instead.

--
J.
Oct 11 '08 #4
>I understand that the new versions of MS Word, MS
>Excel etc. allow for creation of a document using
XML tags (the technique or format is called OOXML,
i think).

Producing an Excel document programmaticall y isn't
hard, because, as you've pointed out, it accepts
XML.
Sorry, i was unclear here. I wish to build up a
FORMATTED Excel document (i.e. with colors, formulas
and all this nice stuff). Is it still not hard?
...if you want "true" Excel sheets (with formulas
and such) using a ControlAdapter and knowledge of
OOXML, but if you're going this far you can
probably directly output OOXML instead.
I'm unclear on "outputting OOXML directly". Would
you like to elaborate? I thought i needed to set up
a String object containing a XML that will "tell"
the computer to color this blue, color that red and
use this and that formula here and there...

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 11 '08 #5
K Viltersten wrote:
>>I understand that the new versions of MS Word, MS Excel etc. allow
for creation of a document using XML tags (the technique or format is
called OOXML, i think).

Producing an Excel document programmaticall y isn't hard, because, as
you've pointed out, it accepts XML.

Sorry, i was unclear here. I wish to build up a FORMATTED Excel document
(i.e. with colors, formulas
and all this nice stuff). Is it still not hard?
This is harder, obviously. Adapting a GridView will get you a table, but
that's about it.
>...if you want "true" Excel sheets (with formulas and such) using a
ControlAdapt er and knowledge of OOXML, but if you're going this far
you can probably directly output OOXML instead.

I'm unclear on "outputting OOXML directly". Would
you like to elaborate? I thought i needed to set up
a String object containing a XML that will "tell"
the computer to color this blue, color that red and
use this and that formula here and there...
Yes, that's basically it (though you don't need to go through a string, just
use XmlWriter or XElement). Writing a GridView to a file is a shortcut to
doing this if all you want is a basic table. If you want to build up an
Excel sheet with all the bells and whistles, you'll have to dig into the
OOXML format. You can make your life easier by designing the sheet(s) you
want in Excel first and saving them, so you can adapt the results rather
than generating things from scratch.

--
J.
Oct 11 '08 #6
>I'm unclear on "outputting OOXML directly". Would
>you like to elaborate? I thought i needed to set up
a String object containing a XML that will "tell"
the computer to color this blue, color that red and
use this and that formula here and there...
If you want to build up an Excel sheet with all the
bells and whistles, you'll have to dig into the
OOXML format. You can make your life easier by
designing the sheet(s) you want in Excel first and
saving them, so you can adapt the results rather
than generating things from scratch.
As far i can see i can't save an Excel document as
XML (OOXML, if you like). Am i missing something? I
took that you ment that i should create a document,
save it as OOXML and then end up having a template
on how to design a formatted document. Did i got it
right? If so, how do i get the OOXML-ized Excel file?

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 11 '08 #7
On Sat, 11 Oct 2008 15:57:09 -0700, K Viltersten <tm**@vilterste n.com>
wrote:
As far i can see i can't save an Excel document as
XML (OOXML, if you like).
Any time you save an Excel document using the native Excel format, that's
exactly what you're doing.
Am i missing something? I
took that you ment that i should create a document, save it as OOXML and
then end up having a template
on how to design a formatted document. Did i got it
right? If so, how do i get the OOXML-ized Excel file?
Your questions are really much more appropriate for a newsgroup
specifically about the use of Office and/or Excel.

Briefly: the Office 2007 file format is basically a ZIP file with some XML
files contained within. For your own program to create a document in this
format that Excel can read, you need to comply exactly with the
appropriate file format, including creating the XML exactly to the Excel
specification and storing it inside a ZIP-format file with the appropriate
extension (.xlsx for Excel 2007).

As far as the exact file format goes, you need to consult Microsoft's own
documentation for the file format, assuming it exists (I believe that
they've made this format public, but I recall for certain that's true,
never mind do I know off-hand where the documentation might be).

To create one of these files from within Excel for your own reference,
just save your Excel document. The .xlsx file that's written is what
Jeroen is talking about.

Note that this is very different from writing some arbitrary XML file.
Excel does in fact read XML files, and will even provide a default schema
that interprets the XML as a kind of simple textual database file. But
this kind of XML input for Excel will not include any special formatting
or document-specific features that Excel has. It's completely different
from the Excel-specific ".xlsx" XML-based file format.

Pete
Oct 11 '08 #8
>As far i can see i can't save an Excel document as
>XML (OOXML, if you like).

Any time you save an Excel document using the native Excel format, that's
exactly what you're doing.
>Am i missing something? I
took that you ment that i should create a document, save it as OOXML and
then end up having a template
on how to design a formatted document. Did i got it
right? If so, how do i get the OOXML-ized Excel file?

Your questions are really much more appropriate for a newsgroup
specifically about the use of Office and/or Excel.

Briefly: the Office 2007 file format is basically a ZIP file with some XML
files contained within.
<snipping good info>

Great. I think my brains swallowed it now.
Thanks a lot to both of you, guys!

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Oct 12 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
8900
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save this out of an XML file or Excel Template file. Next I need to convert a dataset to xml and try and transform this data into the users xml file..........i've seen a few things on this but havent had much success...
0
3946
by: volume | last post by:
Hi all, In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet! We are a small ticketing company - not a bunch of IT whiz kids. ...but I do have an IT background. I have been successful in logging (printing) tickets to a word document, and it all works kinda cool. However, I wish to log to same information to...
1
1071
by: Guilherme Martins | last post by:
Hi, I need to generate an excel document with an image but I don’t know how do it. I have found a lot of articles showing how to generate a document only with text, but I didn’t found anyone that shows how to generate an excel document with images. Anyone knows how can I do it?
4
3200
by: Josh Behl | last post by:
When I try to programmatically open an existing Excel document using a custom windows form, it works perfectly. I instanciate a new instance of the Excel.ApplicationClass and then set the Visible property to 'true'...then I open the workbook in question via my code..... However, when I try this using ASP.NET. It does not work. I've messed around and gave full access and control to my ASPNET user to practically every darn folder on...
1
3701
by: Bon | last post by:
Hello all I create a form with three buttons in MS Access 2000. They are Open Excel Template, Save Draft and Save Final. When I click the Open Excel Template button, the Excel template will be opened. Inside the Excel template, I have assigned a draft watermark to the Print icon. When the Print icon is clicked, the draft watermark and print dialog box is shown. After the user print/edit data in the Excel template, s/he has to click
0
1396
by: exportación de ficheros excel a XML | last post by:
I have a problem when I try to export an excel document to xml format in excel, I have a list that is repeated many times and inside of this list exist another lists that repeated continually too. when I try to export to xml appear a message that tell me is not possible to do that because the format of the layout is not ok to export. like an example I show you this layout, may be you can understand me better. <dato gid="{asdf}">...
6
11618
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
Hello, How can I disable that message/question that appears when my program edits an Excel file? Here's the code: Excel.Application excelApp = new Excel.ApplicationClass(); Excel.Workbook excelWorkbook = excelApp.Workbooks.Open( fileName, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true,
4
2575
by: stephen | last post by:
Hi all, I am working with Excel. I read an excel document using ExcelReader and lets say it has 10 columns. I have to read each record and based on a specified column peform some activites and then write the result at the end of the record (so will have 11 columns in total) At the same time, I am performing other calculations which has to be written at the end of the file (for eg. Total records, ..., ...). Currently, I am using...
6
7394
by: ronparker | last post by:
Hello, This is my first time posting and just my second day using python on mysql, so please be patient with me. I should also say, I am using a linux machine. Using python I was able to make a database and a table. However, I am having difficulty getting the values from an excel and putting them into the table. The Excel document has just three columns, which are: MATCH - this is just a four digit number DATE - this is just a date in the...
0
9586
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
9423
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9861
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
8869
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...
1
7406
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3956
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
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
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.