| | |
VC++ and MSExcel 2003 sheets handling
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Here is one way to do it , I think, without the complications of COM. The GUI interface is probably not what you want but you can extract the ideas that document presents.
Last edited by Ancient Dragon; May 20th, 2009 at 9:05 am. Reason: add link
•
•
•
•
Here is one way to do it without the complications of COM.

At OP:
You might want to use CSV-files from excel. The CSV files can easily be opened and edited with C++ because they are plain text, so no need for COM
•
•
Join Date: May 2009
Posts: 3
Reputation:
Solved Threads: 0
I found the way myself. This is the code that works:
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ XlsFile = String::Format("Z:\\Documenti\\Lavoro\\Fatture\\2009\\Fattura_02_AEM_marzo_09.xls");
String^ XlsSheet = String::Format("Milano, {0}/{1}/{2}",
dateTimePicker1->Value.Day.ToString(),
dateTimePicker1->Value.Month.ToString(),
dateTimePicker1->Value.Year.ToString());
Excel::Application^ oXLApp;
Excel::Workbook^ oXLWBook;
//Excel::Sheets^ oXLSheet;
//Excel::Worksheet^ oXLWSheet;
Excel::Range^ rng;
//starts Excel application
oXLApp = (gcnew Excel::Application());
oXLApp->Visible = true;
//opens the workbook of the file "XlsFile"
oXLWBook = oXLApp->Workbooks->Open(XlsFile, 0, false, 5, "", "",
true,Excel::XlPlatform::xlWindows, "\t", true, false, 0, false, true, true);
//updates the range of sheet1, cell D4
rng = oXLApp->Range::get("D4","D4");
rng->Value2 = XlsSheet;
}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ XlsFile = String::Format("Z:\\Documenti\\Lavoro\\Fatture\\2009\\Fattura_02_AEM_marzo_09.xls");
String^ XlsSheet = String::Format("Milano, {0}/{1}/{2}",
dateTimePicker1->Value.Day.ToString(),
dateTimePicker1->Value.Month.ToString(),
dateTimePicker1->Value.Year.ToString());
Excel::Application^ oXLApp;
Excel::Workbook^ oXLWBook;
//Excel::Sheets^ oXLSheet;
//Excel::Worksheet^ oXLWSheet;
Excel::Range^ rng;
//starts Excel application
oXLApp = (gcnew Excel::Application());
oXLApp->Visible = true;
//opens the workbook of the file "XlsFile"
oXLWBook = oXLApp->Workbooks->Open(XlsFile, 0, false, 5, "", "",
true,Excel::XlPlatform::xlWindows, "\t", true, false, 0, false, true, true);
//updates the range of sheet1, cell D4
rng = oXLApp->Range::get("D4","D4");
rng->Value2 = XlsSheet;
}
![]() |
Similar Threads
- Outlook 2003 receives everything in Plain Text (Windows NT / 2000 / XP)
- opening Excel 2003 file by c# (C#)
- Outlook 2003 different views from different clients (Windows NT / 2000 / XP)
- How to import Excel Sheet data into SQL Server 2003 ???? Stpes. (MS SQL)
- TechNet TV - Visual Studio 2003 ....... (VB.NET)
- FS: HP LaserJet 4100N with 5 Year Extended Warranty (USB Devices and other Peripherals)
Other Threads in the C++ Forum
- Previous Thread: mfc graphic editor visual studio 6.0
- Next Thread: Confusing C++ syntax
Views: 256 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






