Francois Gatto a écrit :

Sebastien Remy wrote:
Bonjour à tous,
j'écris pour savoir si quelqu'un a la réponse a un problème assez
étrange... J'ai une macro qui colle des données (plusieurs séries) dans
un fichier calc
D'où proviennent les données ?

et qui sauvegarde au format pdf.

Bon, je crois suivre jusque là.

Lorsque je lance cette
macro d'une traite,

Oui.

je n'ai que la première série de données dans les
diagrammes,

Etrange !

mais si je pose un point d'arrêt, même en l'exécutant très
rapidement, toutes les séries apparaissent.
J'ai écrit un wait juste avant de sauvegarder en pdf, mais cela ne
semble pas suffisant.
Ma question est donc la suivante : est-ce que ca ne fonctionne pas quand
je lance la macro d'une traite parce que les diagrammes n'ont pas
assimilé la première série de données et que la seconde arrive, ou
est-ce, solution de facilité, un bug ?

Bug ? Je ne sais pas, je n'ai pas cherché.

Mais il m'est arrivé de devoir traité une table de  16000 lignes
environs. ET l'export PDF n'a pas présenté de problème (quelques
dizaines de secondes). Par contre la génération du chart était ...
absolument épuisante ... par pour moi, malgré une certaine impatience,
mais pour mon pôvre processeur !

Tu peux imaginer le temps ... inteeermiiiiidaaaaableeeeeeeeeee.
Mais le résultat a fini par arriver (ouf!)

Ma conclusion, de mémoire, est que c'est bien le chart qui est grand
consommateur de ressources et que La Fontaine semble avoir, à propos de
la patience, toujours raison.


J'espère que j'ai été clair...

Je crois.

La macro est assez longue, donc je ne
l'ai pas jointe (je ne pense pas que ce soit indispensable).

Indispensable, certes non ! Mais interessante, certes oui ;)
Car, il y a plus d'une voies pour réaliser un traitement, et en la
matière l'API d'OOo permet des traitements non similaires, bien
qu'isofonctionnels, en terme de consommation CPU et temps.

J'espère que quelqu'un pourra m'aider !!!

Toujours est-il que cela avait fonctionné.
16000 lignes, un datapilot, un chart sur une plage de 2000 lignes (à
quelques choses près).

Merci d'avance
REMY Sébastien


Une idée plus précise de ton/tes traitement(s) ne serait pas inutile.
Encore que ... pas forcément significative selon (peut-être) la config
du poste.


Ok, je vais essayer d'expliquer plus correctement. J'ai une boucle for qui effectue un copier coller de lignes de données d'un fichier calc vers un autre fichier calc. Ce deuxième fichier contient des diagrammes générés à partir de mes données collées. Ensuite, le fichier est sauvegardé sous forme pdf. Avec un wait après la fin de la boucle et le début d'exportation en pdf, l'actualisation est apparemment aléatoire... Des fois ca marche, des fois non, et quelque soit la durée du wait ! Avec un wait juste après le début de la boucle, ca a l'air de marcher, comme quand je lance le programme étape par étape.
C'est grave docteur ?
Je joint la macro cette fois ci. Le problème se situe dans la troisième macro, appelée par la première.
Merci d'avance, et merci à François Gatto pour sa précédente réponse
REMY Sébastien


option explicit

private entree as object, sortie as object, sortiehebd as object

sub trimsiege (debuttrim as double, fintrim as double)

dim propf(0) as New com.sun.star.beans.PropertyValue
dim f0Entree as object, f1Entree as object, f1Sortie as object, f3SortieHebd as object
dim nom as string
dim adresse as string
dim codepost as string
dim ville as string
dim cellule as object
dim Curs1 as object
dim UneCellule1 as object
dim n as double
dim consofioul as double, coutfioul as double, consopropane as double, coutpropane as double dim consogaz as double, coutgaz as double, consourbain as double, couturbain as double dim consoelec as double, coutelec as double, consoeau as double, couteau as double dim ratioelec as double, ratiochauf as double, ratioeau as double, increment as double
dim i as double
dim LigneCellule as double
dim Curs2 as object
dim UneCellule2 as object
dim n2 as double
dim j as double
dim combust as string
dim k as double, l as double
dim MaZone as object
dim DescrTri as variant
dim ConfigTri(0) as New com.sun.star.table.TableSortField
dim styleFam as object
dim stylePageStd as object
dim MaZone1 as object, MaZone2 as object, MaZone3 as object, maZone4 as object, maZone5 as object
dim AdrZone(4) as New com.sun.star.table.CellRangeAddress
dim adress as string

propf(0).Name = "FilterName"
propf(0).Value = "calc_pdf_Export"

f0Entree = entree.sheets(0)
f1Entree = entree.sheets(1)
f1Sortie = sortie.sheets(1)
f3SortieHebd = SortieHebd.sheets(3)

nom = f0Entree.GetCellByPosition(2,13).String
adresse = f0Entree.GetCellByPosition(3,13).String
codepost = f0Entree.GetCellByPosition(4,13).String
ville = f0Entree.GetCellByPosition(5,13).String

cellule = f3SortieHebd.GetCellByPosition(0,1)

Curs1 = f1Sortie.CreateCursor
Curs1.GoToEndOfUsedArea(false)
UneCellule1 = Curs1.GetCellByPosition(0,0)
n = UneCellule1.CellAddress.row

consofioul = 0
coutfioul = 0
consopropane = 0
coutpropane = 0
consogaz = 0
coutgaz = 0
consourbain = 0
couturbain = 0
consoelec = 0
coutelec = 0
consoeau = 0
couteau = 0
ratioelec = 0
ratiochauf = 0
ratioeau = 0
increment = 0

for i = 1 to n-2
   wait 1000
   if f1Sortie.GetCellByPosition(3,i+2).Value = fintrim then
       LigneCellule = cellule.CellAddress.row
f3SortieHebd.GetCellByPosition(0,LigneCellule).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(1,LigneCellule).String = f1Sortie.GetCellByPosition(1,i+2).String f3SortieHebd.GetCellByPosition(2,LigneCellule).Value = f1Sortie.GetCellByPosition(9,i+2).Value f3SortieHebd.GetCellByPosition(3,LigneCellule).Value = f1Sortie.GetCellByPosition(13,i+2).Value f3SortieHebd.GetCellByPosition(4,LigneCellule).Value = f1Sortie.GetCellByPosition(19,i+2).Value Curs2 = f1Entree.CreateCursor
       Curs2.GoToEndOfUsedArea(false)
       UneCellule2 = Curs2.GetCellByPosition(0,0)
       n2 = UneCellule2.CellAddress.row
for j = 1 to n2 if f1Entree.GetCellByPosition(0,j).Value = f1Sortie.GetCellByPosition(0,i+2).Value then
               combust = f1Entree.GetCellByPosition(8,j).String
               exit for
           end if
       next
if combust = "fioul" then consofioul = consofioul + f1Sortie.GetCellByPosition(18,i+2).Value
           coutfioul = coutfioul + f1Sortie.GetCellByPosition(19,i+2).Value
       elseif combust = "propane GPL" then
consopropane = consopropane + f1Sortie.GetCellByPosition(18,i+2).Value coutpropane = coutpropane + f1Sortie.GetCellByPosition(19,i+2).Value
       elseif combust = "gaz naturel" then
           consogaz = consogaz + f1Sortie.GetCellByPosition(18,i+2).Value
           coutgaz = coutgaz + f1Sortie.GetCellByPosition(19,i+2).Value
       elseif combust = "chauffage urbain" then
consourbain = consourbain + f1Sortie.GetCellByPosition(18,i+2).Value couturbain = couturbain + f1Sortie.GetCellByPosition(19,i+2).Value
       end if
consoelec = consoelec + f1Sortie.GetCellByPosition(8,i+2).Value
       coutelec = coutelec + f1Sortie.GetCellByPosition(9,i+2).Value
       consoeau = consoeau + f1Sortie.GetCellByPosition(12,i+2).Value
       couteau = couteau + f1Sortie.GetCellByPosition(13,i+2).Value
if f3SortieHebd.GetCellByPosition(18,108).Value <> 0 then
           f3SortieHebd.rows.InsertByIndex(108,1)
       end if
f3SortieHebd.GetCellByPosition(18,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(21,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(24,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(27,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(30,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(33,108).Value = f1Sortie.GetCellByPosition(0,i+2).Value f3SortieHebd.GetCellByPosition(19,108).Value = f1Sortie.GetCellByPosition(9,i+2).Value f3SortieHebd.GetCellByPosition(22,108).Value = f1Sortie.GetCellByPosition(6,i+2).Value f3SortieHebd.GetCellByPosition(25,108).Value = f1Sortie.GetCellByPosition(19,i+2).Value f3SortieHebd.GetCellByPosition(28,108).Value = f1Sortie.GetCellByPosition(16,i+2).Value f3SortieHebd.GetCellByPosition(31,108).Value = f1Sortie.GetCellByPosition(13,i+2).Value f3SortieHebd.GetCellByPosition(34,108).Value = f1Sortie.GetCellByPosition(11,i+2).Value ratioelec = ratioelec + f1Sortie.GetCellByPosition(6,i+2).Value
       ratiochauf = ratiochauf + f1Sortie.GetCellByPosition(16,i+2).Value
       ratioeau = ratioeau + f1Sortie.GetCellByPosition(11,i+2).Value
       increment = increment + 1
   end if
cellule = f3SortieHebd.GetCellByPosition(0,LigneCellule+1)
next

f3SortieHebd.GetCellByPosition(7,55).String = CDateFromIso(debuttrim) &" au "& CDateFromIso(fintrim)
f3SortieHebd.GetCellByPosition(5,58).String = nom
f3SortieHebd.GetCellByPosition(5,59).String = adresse
f3SortieHebd.GetCellByPosition(5,60).String = codepost &" " &ville

f3SortieHebd.GetCellByPosition(6,64).Value = consourbain
f3SortieHebd.GetCellByPosition(6,65).Value = couturbain
f3SortieHebd.GetCellByPosition(7,64).Value = consogaz
f3SortieHebd.GetCellByPosition(7,65).Value = coutgaz
f3SortieHebd.GetCellByPosition(8,64).Value = consoelec
f3SortieHebd.GetCellByPosition(8,65).Value = coutelec
f3SortieHebd.GetCellByPosition(9,64).Value = consopropane
f3SortieHebd.GetCellByPosition(9,65).Value = coutpropane
f3SortieHebd.GetCellByPosition(10,64).Value = consofioul
f3SortieHebd.GetCellByPosition(10,65).Value = coutfioul
f3SortieHebd.GetCellByPosition(7,68).Value = consoeau
f3SortieHebd.GetCellByPosition(7,69).Value = couteau

f3SortieHebd.GetCellByPosition(12,64).Value = couturbain
f3SortieHebd.GetCellByPosition(13,64).Value = coutgaz
f3SortieHebd.GetCellByPosition(14,64).Value = coutelec
f3SortieHebd.GetCellByPosition(15,64).Value = coutpropane
f3SortieHebd.GetCellByPosition(16,64).Value = coutfioul
f3SortieHebd.GetCellByPosition(17,64).Value = couteau

if increment = 0 then
   MsgBox("Aucun ratio trimestriel n'a été calculé")
   exit sub
end if

for k = 1 to increment
   f3SortieHebd.GetCellByPosition(20,107+k).Value = coutelec/increment
   f3SortieHebd.GetCellByPosition(23,107+k).Value = ratioelec/increment
f3SortieHebd.GetCellByPosition(26,107+k).Value = (couturbain+coutgaz+coutfioul+coutpropane)/increment
   f3SortieHebd.GetCellByPosition(29,107+k).Value = ratiochauf/increment
   f3SortieHebd.GetCellByPosition(32,107+k).Value = couteau/increment
   f3SortieHebd.GetCellByPosition(35,107+k).Value = ratioeau/increment
next

for l = 1 to 6
MaZone = f3SortieHebd.getCellRangeByPosition(18+(l-1)*3, 108, 20+(l-1)*3, 108+increment)
   with ConfigTri(0)
       .Field=1
       .IsAscending = true
   end with
   DescrTri = MaZone.CreateSortDescriptor
   SetPropval(DescrTri, "SortFields", ConfigTri())
   SetPropval(DescrTri, "IsSortColumns", false)
   SetPropval(DescrTri, "IsSortIntable", true)
   MaZone.sort(DescrTri())
next

wait 1000

styleFam = sortiehebd.StyleFamilies
stylePageStd = styleFam.getByIndex(1).getByIndex(0)
With stylePageStd
     .HeaderIsOn = False
     .FooterIsOn = False
End With

maZone1 = f3SortieHebd.getCellRangeByName("A1:E55")
maZone2 = f3SortieHebd.getCellRangeByName("F56:K107")
maZone3 = f3SortieHebd.getCellRangeByName("S56:W107")
maZone4 = f3SortieHebd.getCellRangeByName("X56:AB107")
maZone5 = f3SortieHebd.getCellRangeByName("AC56:AG107")
AdrZone(0) = maZone1.RangeAddress
AdrZone(1) = maZone2.RangeAddress
AdrZone(2) = maZone3.RangeAddress
AdrZone(3) = maZone4.RangeAddress
AdrZone(4) = maZone5.RangeAddress
f3SortieHebd.PrintAreas = adrZone()
adress = ConvertToURL("/home/sebastien/helios/home/SIME/SIME/Sorties trimestrielles siege/" _
       &debuttrim &" au "& fintrim &".pdf")
sortiehebd.StoreToURL(adress, propf())
f3SortieHebd.PrintAreas = Array()

end sub


sub SetPropval(descr as variant, NomProp as string, ValProp as variant)
const titre = "Tableau de propriétés"
dim x as long
for x=0 to UBound(descr)
   if descr(x).Name = NomProp then
       descr(x).Value = ValProp
   end if
next

end sub

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Répondre à