1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| //Nombre de tables dans le DOC
Nb_Tables = WD_Document.OlePropertyGet("Tables").OlePropertyGet("Count");
for (Tb = 1; Tb <= Nb_Tables; Tb++)
{
//Table sélectionnée
Tables =WD_Document.OlePropertyGet("Tables").OleFunction("Item", Tb); //sélection table 1
//Nombre de lignes de la table sélectionnée
Nb_Lignes = WD_Document.OlePropertyGet("Tables").OleFunction("Item", Tb).OlePropertyGet("Rows").
OlePropertyGet("Count");
//Nombre de colonnes de la table sélectionnée
Nb_Colonnes = WD_Document.OlePropertyGet("Tables").OleFunction("Item",Tb).OlePropertyGet("Columns").
OlePropertyGet("Count");
for ( Lg = 1; Lg <= Nb_Lignes; Lg++)
{
for ( Cl = 1; Cl <= Nb_Colonnes; Cl++)
{
//Sélection du texte présent dans la cellule.
Cell_Contenu = WD_Document.OlePropertyGet("Tables").OleFunction("Item", Tb).OleFunction("Cell", Lg ,Cl).
OlePropertyGet("Range").OlePropertyGet("Text");
Texte_cellule = Cell_Contenu; // transtipage Variant --> String
Texte_cellule = Texte_cellule.SubString(1,(Texte_cellule.Length() -2));
// Enlever les mauvais caractères et indenter les bullets sur trois niveaux
longueur = Texte_cellule.Length();
for(L = 1; L <= longueur; L++)
{
cara = Texte_cellule[L];
if(cara == '\t')
{
Texte_cellule.Delete(L,1);
Texte_cellule.Insert(" ", L);
}
if(cara == '\f')
{
Texte_cellule.Delete(L,1);
Texte_cellule.Insert(" ", L);
}
if(cara == '\r')
{
Texte_cellule.Delete(L,1);
Texte_cellule.Insert('\n', L);
// Si numérique en début de ligne alors ajout de blancs
numerique = Texte_cellule[L+1];
if ( (numerique > '0') && (numerique <='9') || (numerique =='-'))
{
Texte_cellule.Insert(" ", L+1);
longueur = longueur + 5;
point = Texte_cellule[L+5+2];
if (point == '.')
{
Texte_cellule.Insert(" ", L+4+2);
longueur = longueur + 5;
point = Texte_cellule[L+10+4];
if (point == '.')
{
Texte_cellule.Insert(" ", L+8+3);
longueur = longueur + 5;
}
}
}
}
if(cara == '\a')
{
Texte_cellule.Delete(L,1);
Texte_cellule.Insert("|", L);
}
if(cara == '\0')
{
Texte_cellule.Delete(L,1);
Texte_cellule.Insert('\b', L);
}
}
// Placement du texte dans la cellule Excel
if( (CB1->Checked) && (Cl ==2)&& (Texte_cellule != ""))
{
Texte_cellule = Attribution + "_" + Texte_cellule;
}
EX_Feuille.OlePropertyGet("Cells").OlePropertyGet("Item", Num_ligne, Cl).
OlePropertySet("Value", Texte_cellule.c_str());
//Formatage de la cellule.
EX_Feuille.OlePropertyGet("Cells",Num_ligne,1).OlePropertySet("WrapText", true);
EX_Feuille.OlePropertyGet("Cells", Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("Name", "Arial Narrow");
EX_Feuille.OlePropertyGet("Cells", Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("Size",10);
if (Cl > 1)
{
EX_Feuille.OlePropertyGet("Cells", Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("Size",7);
}
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("Bold",false);
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("Italic",false);
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl).
OlePropertyGet("Font").OlePropertySet("ColorIndex",0);
if(Cl ==2)
{
EX_Feuille.OlePropertyGet("Cells",Num_ligne, 2).
OlePropertyGet("Font").OlePropertySet("ColorIndex",3);
if( Texte_cellule == "")
{
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl-1).
OlePropertyGet("Font").OlePropertySet("Bold",true);
}
}
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl).
OlePropertySet("HorizontalAlignment",1 );// xlGeneral
EX_Feuille.OlePropertyGet("Cells",Num_ligne, Cl).
OlePropertySet("VerticalAlignment",-4160 );// xlTop
vBorders = EX_Feuille.OlePropertyGet("Cells",Num_ligne,Cl).OlePropertyGet("Borders");
vBorders.OlePropertySet("LineStyle", 1);
}//for Columns
Num_ligne = Num_ligne + 1;
EX_Feuille.OlePropertyGet("Rows", Cl).OleFunction("AutoFit");
}//for Rows
}//for Tables
// fermer fichier WORD
WD_Documents.OleFunction("Close", false, NULL);
ouverture = 0;
WD.OleFunction("Quit");
Edt_Titre_Word->Clear();
// WD = Unassigned;
} |
Partager