-
April 30th, 2010, 09:26 AM
#1
Excel automation
Hi!
I´m building a function that opens a workbook in Excel 2007 from a template. Then I want to copy the formatting from two rows, create new rows with the copied formats and insert data on those rows. This is what I´ve come up with so far:
Code:
Microsoft::Office::Interop::Excel::Application^ exApp;
Microsoft::Office::Interop::Excel::_Workbook^ exBook;
Microsoft::Office::Interop::Excel::_Worksheet^ exSheet;
Microsoft::Office::Interop::Excel::Range^ exRange;
exApp = gcnew Microsoft::Office::Interop::Excel::ApplicationClass();
exBook = exApp->Workbooks->Open(lista->Dokumentmall,Type::Missing,Type::Missing,
Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing,
Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing,Type::Missing);
exSheet = (Microsoft::Office::Interop::Excel::Worksheet^)exBook->ActiveSheet;
exRange = (Microsoft::Office::Interop::Excel::Range^)exSheet->Range("A1","B2");
//exRange->PasteSpecial(..)
exApp->Visible = true;
The exSheet->Range("A1","B2"); part doesnt seem to work. I can only find C# examples and there they always use the get_Range function which doesnt work i C++/CLI. (Why?)
I think that I might be able to use the Worksheet::Copy() and Worksheet::PasteSpecial() functions, or is there a way to use the Format Painter by code?
Anyway, I cant get it right from here.
Please help would be appreciated.
Regards
Matt
.NET 3.5, VS 2008 Express, SQL Server 2008 Express
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
|
Click Here to Expand Forum to Full Width
|