-
Re: How do I use the Excel automation to generate the file?
"ralph" <nt_consulting32@hotmail.com> wrote:
>
>"kenny Szeto" <kenny.szeto@unitron.com> wrote:
>>
>>Hi, I would like to create an EXCEL file in my c++ code. My current code
>>is:
>>
>>HANDLE hFile=CreateFile("c:\\test.xls",GENERIC_WRITE,FILE_SHARE_WRITE,
>> NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
>NULL);
>>
>>However, this creates a text delimited file. I know it creates this because
>>when I save, a message box pops up saying do I want to convert it to Excel
>>97 file. How can I create an excel file so that I won't get a pop up dialog
>>box?
>>
>>Thanks!
>>Kenny
>>
>
>There are 3 major ways to create an "Excel" file.
>
>1) The simplest method is to do what you just tried to do, only instead
of
>a .xls extension, create a "comma-delimited" file and give it a ".csv" extension.
>You can include a "header" line. The disadvantage is of course that "formatting"
>is very limited and it is a "text" file, but .csv files are easily handled
>by Excel without complaint.
>
>Formatting can often by handled by using an Excel "template" when opening
>your file.
>
>2) Use Excel/Office automation to create the file. The best solution for
>complex spreadsheets, formatting, and integration with other office applications.
>The result will be a .xls file/worksheet if you like.
>
>or
>
>3) Get a copy of the BIFF2/4/x file format and create an .xls file from
scratch.
>Be warned that this option is NOT a trivial exercise, and often doesn't
provide
>a result much better than the first option.
>
-
Re: How do I use the Excel automation to generate the file?
"ralph" <nt_consulting32@hotmail.com> wrote:
>
>"kenny Szeto" <kenny.szeto@unitron.com> wrote:
>>
>>Hi, I would like to create an EXCEL file in my c++ code. My current code
>>is:
>>
>>HANDLE hFile=CreateFile("c:\\test.xls",GENERIC_WRITE,FILE_SHARE_WRITE,
>> NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
>NULL);
>>
>>However, this creates a text delimited file. I know it creates this because
>>when I save, a message box pops up saying do I want to convert it to Excel
>>97 file. How can I create an excel file so that I won't get a pop up dialog
>>box?
>>
>>Thanks!
>>Kenny
>>
>
>There are 3 major ways to create an "Excel" file.
>
>1) The simplest method is to do what you just tried to do, only instead
of
>a .xls extension, create a "comma-delimited" file and give it a ".csv" extension.
>You can include a "header" line. The disadvantage is of course that "formatting"
>is very limited and it is a "text" file, but .csv files are easily handled
>by Excel without complaint.
>
>Formatting can often by handled by using an Excel "template" when opening
>your file.
>
>2) Use Excel/Office automation to create the file. The best solution for
>complex spreadsheets, formatting, and integration with other office applications.
>The result will be a .xls file/worksheet if you like.
>
>or
>
>3) Get a copy of the BIFF2/4/x file format and create an .xls file from
scratch.
>Be warned that this option is NOT a trivial exercise, and often doesn't
provide
>a result much better than the first option.
>
I like 2.), but I don't know how to use Excel automation to create the file.
Where can I find the c++ code that will do this automation?
-
Re: How do I use the Excel automation to generate the file?
"kenny Szeto" <kenny.szeo@unitron.com> wrote:
>
>"ralph" <nt_consulting32@hotmail.com> wrote:
>>
>>"kenny Szeto" <kenny.szeto@unitron.com> wrote:
>>>
>>>Hi, I would like to create an EXCEL file in my c++ code. My current code
>>>is:
>>>
>>>HANDLE hFile=CreateFile("c:\\test.xls",GENERIC_WRITE,FILE_SHARE_WRITE,
>>> NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
>>NULL);
>>>
>>>However, this creates a text delimited file. I know it creates this because
>>>when I save, a message box pops up saying do I want to convert it to Excel
>>>97 file. How can I create an excel file so that I won't get a pop up
dialog
>>>box?
>>>
>>>Thanks!
>>>Kenny
>>>
>>
>>There are 3 major ways to create an "Excel" file.
>>
>>1) The simplest method is to do what you just tried to do, only instead
>of
>>a .xls extension, create a "comma-delimited" file and give it a ".csv"
extension.
>>You can include a "header" line. The disadvantage is of course that "formatting"
>>is very limited and it is a "text" file, but .csv files are easily handled
>>by Excel without complaint.
>>
>>Formatting can often by handled by using an Excel "template" when opening
>>your file.
>>
>>2) Use Excel/Office automation to create the file. The best solution for
>>complex spreadsheets, formatting, and integration with other office applications.
>>The result will be a .xls file/worksheet if you like.
>>
>>or
>>
>>3) Get a copy of the BIFF2/4/x file format and create an .xls file from
>scratch.
>>Be warned that this option is NOT a trivial exercise, and often doesn't
>provide
>>a result much better than the first option.
>>
>
>I like 2.), but I don't know how to use Excel automation to create the file.
> Where can I find the c++ code that will do this automation?
>
The MSDN article "Microsoft Office Development with Visual Studio" is probably
as good a place to start as any.
Some of the more interesting "examples" are in VB. This shouldn't be a problem
since once you get past the basics of opening an ActiveX component using
C++ and managing "collections" - the rest of the "calls" are identical and
quite straightforward.
http://msdn.microsoft.com/library/en...ficedev_topic4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks