Excel

maevasa Messages postés 100 Date d'inscription vendredi 23 avril 2004 Statut Membre Dernière intervention 3 août 2004 - 28 juil. 2004 à 09:30
chaker327 Messages postés 2 Date d'inscription dimanche 20 juin 2004 Statut Membre Dernière intervention 30 août 2005 - 30 août 2005 à 21:41
bonjour je souhaiterais encadrer des résultats et agrandir des cellules est ce que quelqu'un serait me dire comment
merci d'avance
Maeva

ps: le code que j'utilise sous visual c++ .net

#include <stdio.h>
#import "C:\Program Files\Microsoft Office\Office\MSO9.DLL" no_namespace rename("DocumentProperties","DocumentPropertiesXL")
//#import "C:\Program Files\Fichiers communs\Microsoft Shared\Office10\MSO.DLL" no_namespace rename("DocumentProperties","DocumentPropertiesXL")
#import "C:\Program Files\Fichiers communs\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" no_namespace
#import "C:\Program Files\Microsoft Office\Office\EXCEL9.OLB" rename("ExitWindows", "ExitWindowsWD") rename("DialogBox", "ExcelDialogBox") rename("RGB", "ExcelRGB") no_dual_interfaces

using namespace std;

int main()
{

// Initialize COM
CoInitialize(NULL);
try
{

Excel::_ApplicationPtr excel;
// Initialize Excel and make sure it's initialized
HRESULT hr = excel.CreateInstance(L"Excel.Application");
if(FAILED(hr))
{
char msg[1024] = {0};
sprintf(msg, "E: There was an error initializing Excel: %d", hr);
//throw std::runtime_error(msg);
}
excel->PutVisible (true);//Put it after instance is created.

Excel::_WorkbookPtr workbook = excel->Workbooks->Add(static_cast<long>(Excel::xlWorksheet)); // Create the workbook
Excel::_WorksheetPtr worksheet = excel->ActiveSheet; // Get the active sheet

worksheet->PutName ("Nom de la feuille");//
// This is how you put the values into the worksheet
worksheet->Range["A1"]->Value = "Hellofddddddddddddddddddddddd"; // Set a value
//worksheet->Columns["A:A"]->Resize = 56; // Set a value
worksheet->Range["A1:D1"]->Font->ColorIndex = 27L;
worksheet->Range["A2:D2"]->Interior->ColorIndex = 5L;

worksheet->SaveAs("c:\\test.xls"); // Save it
workbook->Close(); // Close the workbook
excel->Quit(); // Quit excel
}
catch(_com_error &ce)
{
// Handle the error
}
CoUninitialize();
}

2 réponses

nasrediney Messages postés 1 Date d'inscription mercredi 3 août 2005 Statut Membre Dernière intervention 5 août 2005
5 août 2005 à 01:05
Bonjour,
J'utilise Visual C++,
Encadrer c'est l'une des méthodes de la classe IBorder.(ouvrir le fichier Excel.tli et excel.tlh pour plus d'infos)

Fusionner des cellules c'est la méthode MergeCells:
pFeuille -> Range["A7"]["D9"] -> MergeCells = true;

/*mise en forme:*/
_variant_t align;
VariantInit( &align );
align.vt = VT_I4;
align.lVal = xlCenter;
pXLsApp2 -> ActiveCell -> VerticalAlignment = &align;
pXLsApp2 -> ActiveCell -> HorizontalAlignment = &align;

Bonne continuation.
0
chaker327 Messages postés 2 Date d'inscription dimanche 20 juin 2004 Statut Membre Dernière intervention 30 août 2005
30 août 2005 à 21:41
chaker327
0
Rejoignez-nous