n_dw2xls_requestor.sru 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194
  1. $PBExportHeader$n_dw2xls_requestor.sru
  2. forward
  3. global type n_dw2xls_requestor from nonvisualobject
  4. end type
  5. end forward
  6. global type n_dw2xls_requestor from nonvisualobject
  7. end type
  8. global n_dw2xls_requestor n_dw2xls_requestor
  9. type prototypes
  10. end prototypes
  11. type variables
  12. Private:
  13. DataWindow idw_Requestor
  14. Datastore ids_Requestor
  15. DataWindowChild idwc_Requestor
  16. DataStore ids_Composite
  17. Object ipo_Type
  18. DWObject idwo_Parent
  19. Boolean ib_Child =False
  20. Boolean ib_Nested=False
  21. Int ii_GroupLevels //分组数
  22. Boolean ib_Detail_Begin
  23. Int ii_Rows_Per_Detail=1
  24. Long il_RowCount
  25. Boolean ib_PrintPreview =False
  26. Int ii_PrintColumns
  27. Int ii_PrintColumnsWidth
  28. Int ii_HeaderCount //交叉报表表头区数目
  29. String is_Processing
  30. String is_Units
  31. Long il_X, il_Y //如果当前对象是子数据窗口,则保存子数据窗口的位置
  32. Long il_X2 ,il_Y2
  33. Long il_Header_BeginY =60000
  34. String is_Header_BeginBand ="header"
  35. Long il_BKColor
  36. Boolean ib_GroupNewPage[]
  37. n_dw2xls_band inv_Bands[] //所有带区对象
  38. n_dw2xls_Object inv_ChildReports[]
  39. n_dw2xls_Object inv_NestReports[]
  40. n_dw2xls_Layout inv_Layout
  41. n_dw2xls_winApi inv_Api
  42. n_dw2xls_Progress inv_Progress
  43. n_dw2xls_Expression inv_Exps[]
  44. Long il_LastExpUpdateRow
  45. Int ii_FirstColumn =30000
  46. Int ii_LastColumn
  47. CONSTANT String DW2XLS_BANDCOLOR ='dw2xls_bandcolor'
  48. CONSTANT String DW2XLS_SKIPBORDER = "dw2xls_skipborder"
  49. CONSTANT String DW2XLS_VERSION='4.5.2012.1105' //当前程序的版本号,用于版本跟踪
  50. /*---------------------------------------------------------------------------------
  51. 程序如有问题需要反馈,请与我联系,谢谢!
  52. 黄国酬
  53. EMAIL: huanggc@163.com
  54. QQ: 46875483
  55. HTTP: www.dw2xls.com
  56. ------------------------------------------------------------------------------------*/
  57. end variables
  58. forward prototypes
  59. public function string of_describe (readonly string as_syntax)
  60. public function double of_getitemnumber (readonly long al_row, readonly string as_name)
  61. public function string of_getitemstring (readonly long al_row, readonly string as_name)
  62. public function n_dw2xls_band of_getband (readonly string as_name)
  63. public function string of_describe (readonly string as_name, readonly string as_property)
  64. public subroutine of_getproperty (readonly string as_name, readonly string as_property, ref string as_value, ref string as_exp)
  65. public function boolean of_containtband (string as_name)
  66. public function string of_modify (readonly string as_syntax)
  67. public function String of_getprocessing ()
  68. public function String of_getunits ()
  69. public function long of_rowcount ()
  70. public function datetime of_getitemdatetime (readonly long al_row, readonly string as_name)
  71. public function date of_getitemdate (readonly long al_row, readonly string as_name)
  72. public subroutine of_getdwinfo ()
  73. private function integer of_getobjects ()
  74. public function time of_getitemtime (readonly long al_row, readonly string as_name)
  75. public function Boolean of_ischild ()
  76. public function string of_evaluate (long al_row, string as_exp)
  77. public subroutine of_getproperty (readonly string as_property, ref string as_value, ref string as_exp)
  78. public function long of_parsetoarray (string as_source, string as_delimiter, ref string as_array[])
  79. protected function long of_lastpos (string as_source, string as_target, long al_start)
  80. protected function long of_lastpos (string as_source, string as_target)
  81. public function long of_arraytostring (readonly string as_source[], readonly string as_delimiter, ref string as_ref_string)
  82. public function string of_replaceall (readonly string as_oldstr, readonly string as_findstr, readonly string as_repstr)
  83. public subroutine of_dataformat (ref string as_format, ref string as_exp, string as_coltype)
  84. public function long of_findgroupchange (readonly long al_row, readonly integer ai_level)
  85. public subroutine of_getrowindetail ()
  86. public subroutine of_getsparse ()
  87. public function string of_getnextband (readonly string as_name)
  88. public subroutine of_setrow (long al_row)
  89. public function n_dw2xls_layout of_getlayout ()
  90. public subroutine of_registcolumninfo ()
  91. public subroutine of_getcolrowinfo ()
  92. public function Long of_getbkcolor ()
  93. public function string of_gettext (readonly long al_row, readonly string as_name, string as_coltype, readonly string as_format)
  94. public function integer of_setrequestor (powerobject apo, ref n_dw2xls_progress anv_progress)
  95. private function integer of_setrequestor (powerobject apo, ref n_dw2xls_progress anv_progress, ref n_dw2xls_layout anv_layout)
  96. public function Boolean of_isdetail_begin ()
  97. public subroutine of_groupcalc ()
  98. public function string of_getheader_beginband ()
  99. public function Boolean of_checkoutpictures ()
  100. public function integer of_clipboard (readonly string as_name)
  101. public subroutine of_setwinapi (n_dw2xls_winapi anv_api)
  102. public function n_dw2xls_winapi of_getwinapi ()
  103. public function Boolean of_iscancel ()
  104. public function Boolean of_isdatawindowchild ()
  105. public function boolean of_iswritepictures ()
  106. public function boolean of_iswritebkcolor ()
  107. public subroutine of_updatecolumninfo ()
  108. public subroutine of_write_printsetting (readonly unsignedlong al_hsheet)
  109. public function double of_getitemnumber (readonly long al_row, readonly integer ai_column)
  110. public function string of_getitemstring (readonly long al_row, readonly integer ai_column)
  111. public function datetime of_getitemdatetime (readonly long al_row, readonly integer ai_column)
  112. public function date of_getitemdate (readonly long al_row, readonly integer ai_column)
  113. public function time of_getitemtime (readonly long al_row, readonly integer ai_column)
  114. public subroutine of_addexpression (ref string as_exp)
  115. public subroutine of_updateexpvalues (readonly long al_row)
  116. public function string of_getexpvalue (readonly string as_exp, readonly integer ai_rowindetail)
  117. public subroutine of_updatereport (readonly long al_row, readonly string as_name, ref n_dw2xls_requestor anv_report)
  118. public function Boolean of_isvalid_dwomaster ()
  119. public function string of_getdisplayvalue (readonly long al_row, readonly integer ai_colid, readonly string as_name, readonly boolean ab_isclone, readonly string as_editstyle, readonly string as_coltype)
  120. public function Integer of_getchild (string as_name, ref datawindowchild adwc)
  121. public function integer of_getchild (readonly long al_row, readonly string as_name, ref dwobject dwo)
  122. public function boolean of_isnested ()
  123. public subroutine of_updatenestreport ()
  124. public subroutine of_registcolumninfo_1 ()
  125. public subroutine of_registcolumninfo_2 ()
  126. public subroutine of_registcolumninfo_3 ()
  127. public subroutine of_getobjectposition (readonly string as_band, readonly string as_type, readonly string as_name, ref long ai_x1, ref long ai_y1, ref long ai_x2, ref long ai_y2, ref string as_x1_exp, ref string as_y1_exp, ref string as_x2_exp, ref string as_y2_exp)
  128. public function Long of_getbandheight (readonly string as_band)
  129. public function long of_getreport_x1 ()
  130. public function Long of_getheader_beginy ()
  131. public function Long of_getcontrolheight ()
  132. public function Long of_getcontrolwidth ()
  133. public function Long of_getreport_x2 ()
  134. public function boolean of_initialreport (n_dw2xls_object anv_object, readonly long ai_x, readonly long ai_y, readonly long ai_x2, readonly long ai_y2)
  135. public function integer of_getfirstcolumn ()
  136. public function integer of_getlastcolumn ()
  137. public subroutine of_setfirstcolumn (readonly integer ai_column)
  138. public subroutine of_setlastcolumn (readonly integer ai_column)
  139. public function integer of_getarguments (readonly long al_row, readonly string as_arguments, string as_nestarguments, ref any aa_argvalue[], ref string as_argtype[])
  140. public function long of_output (readonly unsignedlong al_hsheet, readonly long al_beginrow)
  141. public function integer of_getobject_x1 (readonly string as_name)
  142. public function integer of_getobject_x2 (readonly string as_name)
  143. end prototypes
  144. public function string of_describe (readonly string as_syntax);
  145. String ls_Result
  146. Try
  147. Choose Case ipo_Type
  148. Case DataWindow!
  149. ls_Result= idw_Requestor.Describe(as_Syntax)
  150. Case DataStore!
  151. ls_Result= ids_Requestor.Describe(as_Syntax)
  152. Case DataWindowChild!
  153. ls_Result= idwc_Requestor.Describe(as_Syntax)
  154. END CHOOSE
  155. IF ( Left(ls_Result,1)="'" AND Right(ls_Result,1)="'" ) OR &
  156. ( Left(ls_Result,1)='"' AND Right(ls_Result,1)='"' ) Then
  157. ls_Result = Mid(ls_Result,2, Len(ls_Result) -2)
  158. END IF
  159. Catch(DWRunTimeError dwError)
  160. Return ""
  161. Catch(RuntimeError er)
  162. Return ""
  163. END TRY
  164. Return ls_Result
  165. end function
  166. public function double of_getitemnumber (readonly long al_row, readonly string as_name);IF al_Row<=0 OR al_Row>il_RowCount Then
  167. Return 0
  168. END IF
  169. Choose Case ipo_Type
  170. Case DataWindow!
  171. Return idw_Requestor.GetItemNumber(al_Row,as_Name)
  172. Case DataStore!
  173. Return ids_Requestor.GetItemNumber(al_Row,as_Name)
  174. Case DataWindowChild!
  175. Return idwc_Requestor.GetItemNumber(al_Row,as_Name)
  176. END CHOOSE
  177. Return 0
  178. end function
  179. public function string of_getitemstring (readonly long al_row, readonly string as_name);IF al_Row<=0 OR al_Row>il_RowCount Then
  180. Return""
  181. END IF
  182. Choose Case ipo_Type
  183. Case DataWindow!
  184. Return idw_Requestor.GetItemString(al_Row,as_Name)
  185. Case DataStore!
  186. Return ids_Requestor.GetItemString(al_Row,as_Name)
  187. Case DataWindowChild!
  188. Return idwc_Requestor.GetItemString(al_Row,as_Name)
  189. END CHOOSE
  190. Return ""
  191. end function
  192. public function n_dw2xls_band of_getband (readonly string as_name);Int li
  193. For li=1 To UpperBound(inv_Bands)
  194. IF inv_Bands[li].OF_GetName() = as_Name Then
  195. Return inv_Bands[li]
  196. END IF
  197. Next
  198. li = UpperBound(inv_Bands)+1
  199. inv_Bands[li] = Create n_dw2xls_Band
  200. inv_Bands[li].OF_SetRequestor(This, as_Name )
  201. Return inv_Bands[li]
  202. end function
  203. public function string of_describe (readonly string as_name, readonly string as_property);Return OF_Describe(as_Name+"."+as_Property)
  204. end function
  205. public subroutine of_getproperty (readonly string as_name, readonly string as_property, ref string as_value, ref string as_exp);String ls_Band
  206. OF_GetProperty(as_Name+"."+as_Property, as_Value, as_Exp)
  207. IF as_Exp<>'' AND OF_RowCount()>0 Then
  208. ls_Band =OF_Describe(as_Name+".Band")
  209. IF Pos(ls_Band,"header")>0 OR ls_Band="foreground" OR ls_Band="background" Then
  210. as_Value =OF_Evaluate(1, as_Exp)
  211. as_Exp=""
  212. ELSEIF ls_Band="summary" OR ls_Band="footer" Then
  213. as_Value = OF_Evaluate(OF_RowCount(), as_Exp)
  214. as_Exp=""
  215. END IF
  216. END IF
  217. IF as_Exp<>"" AND Lower(as_Property)<>"visible" Then
  218. OF_AddExpression(as_Exp)
  219. END IF
  220. end subroutine
  221. public function boolean of_containtband (string as_name);Int li
  222. For li=1 To UpperBound(inv_Bands)
  223. IF inv_Bands[li].OF_GetName() = as_Name Then
  224. Return TRUE
  225. END IF
  226. Next
  227. Return False
  228. end function
  229. public function string of_modify (readonly string as_syntax);TRY
  230. Choose Case ipo_Type
  231. Case DataWindow!
  232. Return idw_Requestor.Modify(as_Syntax)
  233. Case DataStore!
  234. Return ids_Requestor.Modify(as_Syntax)
  235. Case DataWindowChild!
  236. Return idwc_Requestor.Modify(as_Syntax)
  237. END CHOOSE
  238. Catch(DWRunTimeError dwError)
  239. MessageBox("OF_Modify Error",dwError.Text+"~r~n~r~nSyntax:~r~n"+as_Syntax,Exclamation!)
  240. Return "!"
  241. Catch(RunTimeError er)
  242. MessageBox("OF_Modify Error",er.Text+"~r~n~r~nSyntax:~r~n"+as_Syntax,Exclamation!)
  243. Return "!"
  244. END TRY
  245. Return "!"
  246. end function
  247. public function String of_getprocessing ();Return is_Processing
  248. end function
  249. public function String of_getunits ();Return is_Units
  250. end function
  251. public function long of_rowcount ();//Choose Case ipo_Type
  252. // Case DataWindow!
  253. // Return idw_Requestor.RowCount()
  254. // Case DataStore!
  255. // Return ids_Requestor.RowCount()
  256. // Case DataWindowChild!
  257. // Return idwc_Requestor.RowCount()
  258. //END CHOOSE
  259. Return il_RowCount
  260. end function
  261. public function datetime of_getitemdatetime (readonly long al_row, readonly string as_name);
  262. IF al_Row<=0 OR al_Row>il_RowCount Then
  263. Return DateTime(1900-01-01,00:00:00)
  264. END IF
  265. Choose Case ipo_Type
  266. Case DataWindow!
  267. Return idw_Requestor.GetItemDateTime(al_Row,as_Name)
  268. Case DataStore!
  269. Return ids_Requestor.GetItemDateTime(al_Row,as_Name)
  270. Case DataWindowChild!
  271. Return idwc_Requestor.GetItemDateTime(al_Row,as_Name)
  272. END CHOOSE
  273. Return DateTime(1900-01-01,00:00:00)
  274. end function
  275. public function date of_getitemdate (readonly long al_row, readonly string as_name);IF al_Row<=0 OR al_Row>il_RowCount Then
  276. Return 1900-01-01
  277. END IF
  278. Choose Case ipo_Type
  279. Case DataWindow!
  280. Return idw_Requestor.GetItemDate(al_Row,as_Name)
  281. Case DataStore!
  282. Return ids_Requestor.GetItemDate(al_Row,as_Name)
  283. Case DataWindowChild!
  284. Return idwc_Requestor.GetItemDate(al_Row,as_Name)
  285. END CHOOSE
  286. Return Date(1900-01-01)
  287. end function
  288. public subroutine of_getdwinfo ();string ls_Temp
  289. int li,li_pos,li_Pos2,li_groupcount
  290. is_Processing = OF_Describe("DataWindow.Processing")
  291. is_Units = OF_Describe("DataWindow.Units")
  292. il_BKColor = inv_Api.OF_GetColor( Long(OF_Describe("DataWindow.Color")) )
  293. IF is_Processing="4" Then
  294. OF_Modify("DataWindow.Crosstab.StaticMode=Yes")
  295. END IF
  296. ls_Temp=OF_Describe("datawindow.bands")
  297. li_pos=1
  298. Do While li_pos>0
  299. li_pos=Pos(ls_Temp,"header.",li_pos)
  300. IF li_pos>0 Then
  301. ii_GroupLevels++
  302. li_pos++
  303. END IF
  304. Loop
  305. li_pos=1
  306. Do While li_pos>0
  307. li_pos=Pos(ls_Temp,"header[",li_pos)
  308. IF li_pos>0 Then
  309. ii_HeaderCount++
  310. li_pos++
  311. END IF
  312. Loop
  313. IF ii_GroupLevels >0 Then
  314. ls_Temp=OF_Describe("datawindow.syntax")
  315. li_Pos=Pos(ls_Temp,"group(level=1 ")
  316. IF li_Pos>0 Then
  317. ls_Temp=Mid(ls_Temp,li_Pos)
  318. li_Pos =1
  319. li=1
  320. END IF
  321. Do While li_Pos>0
  322. li_Pos2=Pos(ls_Temp,"group(level="+String(li+1) )
  323. IF li_Pos2>0 Then
  324. li_Pos= pos(Mid(ls_Temp,li_Pos2 - li_Pos),"newpage=yes")
  325. ELSE
  326. li_Pos= pos(ls_Temp,"newpage=yes",li_Pos)
  327. END IF
  328. IF li_Pos>0 Then
  329. ib_GroupNewPage[li]=True
  330. ELSE
  331. ib_GroupNewPage[li]=False
  332. END IF
  333. li_Pos=li_Pos2
  334. li++
  335. Loop
  336. END IF
  337. IF ii_GroupLevels>0 Then
  338. OF_GroupCalc()
  339. END IF
  340. end subroutine
  341. private function integer of_getobjects ();Long li,lj, li_cnt
  342. Long li_x1, li_y1, li_x2 , li_y2 ,li_Temp, li_Last_X2
  343. String ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp
  344. Long li_BandHeight
  345. String ls_Name, ls_Objects[] , ls_Crosstab_Columns[], ls_Band , ls_Type, ls_Value, ls_Exp,ls_Border
  346. Boolean lb_ForeGround ,lb_BandAutoHeight , lb_SkipBorder
  347. n_dw2xls_Band lnv_Band
  348. n_dw2xls_Object lnv_Object
  349. n_dw2xls_line lnv_Line ,lnv_Line2
  350. n_dw2xls_line lnv_LinesEmpty[]
  351. li_cnt =OF_ParseToArray(OF_Describe("DataWindow.Objects"),"~t",ls_Objects)
  352. IF is_Processing="4" Then
  353. OF_ParseToArray(OF_Describe("DataWindow.Crosstab.Columns"),",",ls_Crosstab_Columns)
  354. is_Header_BeginBand ="header[2]"
  355. ELSEIF is_Processing='3' Then
  356. li_BandHeight=30000
  357. END IF
  358. //对于表格形式的数据窗口,先取得最后可视列的位置
  359. IF is_Processing='1' OR is_Processing='4' Then
  360. For li=1 To li_cnt
  361. ls_Name = ls_Objects[li]
  362. ls_Band = OF_Describe(ls_Name, "Band")
  363. IF ls_Band<>"detail" Then
  364. Continue
  365. END IF
  366. OF_GetProperty(ls_Name, "Visible", ls_Value , ls_Exp)
  367. IF ( ls_Value='0' AND ls_Exp="" ) OR Trim(ls_Exp)='0' Then
  368. Continue
  369. END IF
  370. li_x1 = Long(OF_Describe(ls_Name+".x"))
  371. li_X2 = li_X1 + Long(OF_Describe(ls_Name+".Width"))
  372. IF li_X2>li_Last_X2 Then
  373. li_Last_X2 = li_X2
  374. END IF
  375. NEXT
  376. IF is_Units='1' Then
  377. li_Last_X2 = PixelsToUnits(li_Last_X2, XPixelsToUnits!)
  378. ELSEIF is_Units='2' Then
  379. li_Last_X2 = PixelsToUnits(inv_Api.OF_InchToPixels(li_Last_X2/1000 ) , XPixelsToUnits!)
  380. ELSEIF is_Units='3' Then
  381. li_Last_X2 = PixelsToUnits(inv_Api.OF_CMToPixels(li_Last_X2 /1000), XPixelsToUnits!)
  382. END IF
  383. IF li_Last_X2<0 AND is_Units<>'0' Then
  384. li_Last_X2 +=65536
  385. END IF
  386. //如果子数据窗口是一个Crosstab类型的数据窗口,则Report的位置要根据新的位置更新
  387. IF ib_Child AND is_Processing='4' Then
  388. il_X2 = il_X + li_Last_X2
  389. END IF
  390. END IF
  391. For li=1 To li_cnt
  392. ls_Name = ls_Objects[li]
  393. ls_Type = OF_Describe(ls_Name,"Type")
  394. ls_Band = OF_Describe(ls_Name, "Band")
  395. IF ls_Band="?" OR ls_Band="!" Then
  396. Continue
  397. END IF
  398. OF_GetProperty(ls_Name, "Visible", ls_Value , ls_Exp)
  399. IF ( ls_Value='0' AND ls_Exp="" ) OR Trim(ls_Exp)='0' Then
  400. Continue
  401. END IF
  402. IF ( is_Processing='1' OR is_Processing='4' ) Then
  403. ls_Border = OF_Describe(ls_Name,"Border")
  404. IF ls_Border='4' AND ( ls_Band="foreground" OR ls_Band="background" ) Then
  405. OF_GetObjectPosition(ls_Band , ls_Type,ls_Name, li_x1, li_y1, li_x2,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp )
  406. IF li_x1<100 AND (li_X2+100)>li_Last_X2 Then
  407. IF li_Y2<il_Header_BeginY AND li_Y2>0 Then
  408. il_Header_BeginY = li_Y2
  409. END IF
  410. END IF
  411. END IF
  412. IF ( ls_Band="foreground" OR ls_Band="background" ) AND ls_Type="text" Then
  413. IF OF_Describe(ls_Name+".Text")="" Then
  414. Continue
  415. END IF
  416. END IF
  417. IF ls_Name="sys_lastcol" AND ls_Band='detail' Then
  418. Continue
  419. END IF
  420. IF is_Processing="1" Then
  421. IF ls_Band="header" AND ( ls_Type="text" OR ls_Type="column" OR ls_Type="compute" ) Then
  422. li_Y1 = Long(OF_Describe(ls_Name+".Y"))
  423. IF li_Y1<il_Header_BeginY Then
  424. il_Header_BeginY = li_Y1
  425. END IF
  426. END IF
  427. ELSEIF is_Processing="4" AND Pos(ls_Band,"header")>0 Then
  428. For lj=1 To UpperBound(ls_Crosstab_Columns)
  429. IF ls_Name =ls_Crosstab_Columns[lj]+"_t" Then
  430. li_Y1 = Long(OF_Describe(ls_Name+".Y"))
  431. IF li_Y1<il_Header_BeginY Then
  432. il_Header_BeginY = li_Y1
  433. is_Header_BeginBand = ls_Band
  434. END IF
  435. Exit
  436. END IF
  437. NEXT
  438. END IF
  439. END IF
  440. IF ls_Band="foreground" OR ls_Band="background" Then
  441. IF is_Processing='4' Then
  442. ls_Band="header[1]"
  443. ELSE
  444. ls_Band="header"
  445. END IF
  446. lb_ForeGround =TRUE
  447. ELSE
  448. lb_ForeGround=False
  449. END IF
  450. IF is_Processing<>'3' Then
  451. lb_BandAutoHeight =False
  452. IF Not lb_ForeGround Then
  453. IF OF_Describe("DataWindow."+ls_Band+".Height.AutoSize")="yes" Then
  454. lb_BandAutoHeight =TRUE
  455. END IF
  456. END IF
  457. li_BandHeight =OF_GetBandHeight(ls_Band)
  458. IF li_BandHeight=0 AND lb_BandAutoHeight=False Then
  459. //如果隐藏了细节区,则直接注册登记列的起止位置
  460. IF is_Processing='1' OR is_Processing='4' AND ls_Band="detail" Then
  461. li_X1= OF_GetObject_X1( ls_Name)
  462. IF OF_IsChild() Then
  463. inv_Layout.OF_RegistObject(li_X1 ,TRUE )
  464. ELSE
  465. inv_Layout.OF_RegistColumn(li_X1)
  466. END IF
  467. END IF
  468. Continue
  469. END IF
  470. END IF
  471. //无效的计算公式
  472. IF ls_Type="compute" Then
  473. ls_Value=OF_Describe(ls_Name+".ColType")
  474. IF ls_Value="" OR ls_Value="!" OR ls_Value="?" Then
  475. Continue
  476. END IF
  477. END IF
  478. IF Lower(OF_Describe(ls_Name+".tag"))=DW2XLS_BANDCOLOR Then
  479. lnv_Band = OF_GetBand(ls_Band)
  480. IF ls_Type="rectangle" OR ls_Type="roundrectangle" Then
  481. OF_GetProperty(ls_Name, "Brush.Color", ls_Value , ls_Exp)
  482. ELSE
  483. OF_GetProperty(ls_Name, "BackGround.Color", ls_Value , ls_Exp)
  484. END IF
  485. lnv_Band.OF_SetBKColor(Long(ls_Value), ls_Exp)
  486. Continue
  487. END IF
  488. IF Pos(Lower(OF_Describe(ls_Name+".tag")),DW2XLS_SKIPBORDER)>0 Then
  489. lb_SkipBorder =TRUE
  490. ELSE
  491. lb_SkipBorder =False
  492. END IF
  493. Choose Case ls_Type
  494. Case "line","rectangle","roundrectangle"
  495. //如果是Grid或Crosstab形式的数据窗口,则忽略线条
  496. IF is_Processing="1" OR is_Processing="4" OR lb_SkipBorder Then
  497. Continue
  498. END IF
  499. OF_GetObjectPosition(ls_Band , ls_Type,ls_Name, li_x1, li_y1, li_x2,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp )
  500. IF li_y1>li_BandHeight AND lb_BandAutoHeight=False Then
  501. Continue
  502. END IF
  503. IF li_y2>li_BandHeight AND lb_BandAutoHeight=False Then
  504. li_Y2= li_BandHeight
  505. END IF
  506. lnv_Band = OF_GetBand(ls_Band)
  507. li_x1 = li_x1 +il_x
  508. li_x2 = li_x2 +il_x
  509. IF ib_Child Then
  510. IF li_X1>il_x2 Then
  511. Continue
  512. END IF
  513. IF li_X2>il_x2 Then
  514. li_X2 = il_x2
  515. END IF
  516. END IF
  517. IF ls_Type="line" Then
  518. IF ( li_x2 - li_x1)>=100 AND (li_y2 - li_y1)<=5 Then //横线
  519. lnv_Line =Create n_dw2xls_Line
  520. lnv_Line.VisibleExp = ls_Exp
  521. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp)
  522. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name, TRUE )
  523. lnv_Band.OF_AddHLine(lnv_Line)
  524. ELSEIF (li_y2 - li_y1)>=50 AND (li_x2 - li_x1)<=5 Then //竖线
  525. lnv_Line =Create n_dw2xls_Line
  526. lnv_Line.VisibleExp = ls_Exp
  527. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp)
  528. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name,FALSE )
  529. lnv_Band.OF_AddVLine(lnv_Line)
  530. END IF
  531. ELSE
  532. IF ( li_x2 - li_x1)>=100 AND (li_y2 - li_y1)>=50 Then //当成四条线
  533. lnv_Line =Create n_dw2xls_Line
  534. lnv_Line.VisibleExp = ls_Exp
  535. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y1 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //上
  536. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name , TRUE )
  537. lnv_Band.OF_AddHLine(lnv_Line)
  538. lnv_Line =Create n_dw2xls_Line
  539. lnv_Line.VisibleExp = ls_Exp
  540. lnv_Line.OF_SetPosition(li_x1, li_y2, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //下
  541. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name ,TRUE )
  542. lnv_Band.OF_AddHLine(lnv_Line)
  543. lnv_Line =Create n_dw2xls_Line
  544. lnv_Line.VisibleExp = ls_Exp
  545. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x1 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //左
  546. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name,FALSE )
  547. lnv_Band.OF_AddVLine(lnv_Line)
  548. lnv_Line =Create n_dw2xls_Line
  549. lnv_Line.VisibleExp = ls_Exp
  550. lnv_Line.OF_SetPosition(li_x2, li_y1, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //右
  551. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name, FALSE )
  552. lnv_Band.OF_AddVLine(lnv_Line)
  553. ELSEIF ( li_x2 - li_x1)>=100 AND (li_y2 - li_y1)<30 Then //当成一条横线
  554. lnv_Line =Create n_dw2xls_Line
  555. lnv_Line.VisibleExp = ls_Exp
  556. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y1 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y1_Exp)
  557. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name ,TRUE )
  558. lnv_Band.OF_AddHLine(lnv_Line)
  559. ELSEIF ( li_x2 - li_x1)<30 AND (li_y2 - li_y1)>=50 Then //当成一条竖线
  560. lnv_Line =Create n_dw2xls_Line
  561. lnv_Line.VisibleExp = ls_Exp
  562. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x1 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X1_Exp, ls_Y2_Exp)
  563. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name ,FALSE )
  564. lnv_Band.OF_AddVLine(lnv_Line)
  565. END IF
  566. END IF
  567. Continue
  568. Case "ole","ellipse","oval" ,"tableblob" , "button","groupbox" //以下对象不支持 //
  569. Continue
  570. Case Else
  571. OF_GetObjectPosition(ls_Band , ls_Type,ls_Name, li_x1, li_y1, li_x2,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp )
  572. IF (li_x2 - li_x1)<=10 Then //如果对象的位置在数据窗口上是看不见的,则不处理该对象
  573. Continue
  574. END IF
  575. IF (li_y2 - li_y1)<=10 Then
  576. IF OF_Describe(ls_name,"Height.AutoSize")<>"yes" Then
  577. Continue
  578. END IF
  579. END IF
  580. IF li_y1>=li_BandHeight AND lb_BandAutoHeight=False Then
  581. Continue
  582. END IF
  583. IF li_y2>li_BandHeight AND lb_BandAutoHeight=False Then
  584. li_Y2= li_BandHeight
  585. END IF
  586. IF ( is_Processing='1' OR is_Processing='4' ) AND lb_ForeGround=False Then
  587. IF li_X1>li_Last_X2 Then //超出Grid的显示列的范围,则表示该对象对象数据列是被隐藏了
  588. Continue
  589. END IF
  590. IF (li_x2 - li_x1)<=30 Then //所在的列宽度大小了,也不导出了
  591. Continue
  592. END IF
  593. END IF
  594. ls_Border =OF_Describe(ls_Name+".Border")
  595. li_x1 = li_x1 +il_x
  596. li_x2 = li_x2 +il_x
  597. IF ib_Child Then
  598. IF ( li_X1+20)>=il_x2 Then
  599. Continue
  600. END IF
  601. IF li_X2>il_x2 Then
  602. li_X2 = il_x2
  603. END IF
  604. END IF
  605. IF ( ls_Border="2" OR ls_Border='4' ) AND is_Processing<>"1" AND is_Processing<>"4" AND &
  606. lb_SkipBorder=False AND( ls_Type="text" OR ls_Type="column" or ls_Type="compute" ) Then
  607. IF ( li_x2 - li_x1)>=100 AND (li_y2 - li_y1)>=50 Then
  608. lnv_Band = OF_GetBand(ls_Band)
  609. IF ls_Border="2" Then
  610. lnv_Line =Create n_dw2xls_Line
  611. lnv_Line.VisibleExp = ls_Exp
  612. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x1 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //左
  613. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name , False )
  614. lnv_Band.OF_AddVLine(lnv_Line)
  615. lnv_Line =Create n_dw2xls_Line
  616. lnv_Line.VisibleExp = ls_Exp
  617. lnv_Line.OF_SetPosition(li_x2, li_y1, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //右
  618. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name,False)
  619. lnv_Band.OF_AddVLine(lnv_Line)
  620. lnv_Line =Create n_dw2xls_Line
  621. lnv_Line.VisibleExp = ls_Exp
  622. lnv_Line.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y1 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //上
  623. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name ,TRUE )
  624. lnv_Band.OF_AddHLine(lnv_Line)
  625. END IF
  626. lnv_Line =Create n_dw2xls_Line
  627. lnv_Line.VisibleExp = ls_Exp
  628. lnv_Line.OF_SetPosition(li_x1, li_y2, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //下
  629. lnv_Line.OF_SetRequestor(This, ls_Type, ls_Name ,TRUE )
  630. lnv_Band.OF_AddHLine(lnv_Line)
  631. END IF
  632. END IF
  633. END CHOOSE
  634. //如果文本对象只是用于设置边框,则在输出时忽略该对象
  635. IF ls_Type="text" AND ( ls_Border='2' OR ls_Border='4' ) Then
  636. IF OF_Describe(ls_Name+".Text")="" Then
  637. Continue
  638. END IF
  639. END IF
  640. lnv_Band = OF_GetBand(ls_Band)
  641. IF lnv_Band.OF_ExistsObject(ls_Name) Then
  642. Continue
  643. END IF
  644. lnv_Object = Create n_dw2xls_Object
  645. lnv_Object.IsForeGround = lb_ForeGround
  646. lnv_Object.VisibleExp = ls_Exp
  647. lnv_Object.SkipBorder = lb_SkipBorder
  648. lnv_Object.OF_SetPosition(li_x1, li_y1, li_x2 ,li_y2 ,ls_X1_Exp , ls_Y1_Exp, ls_X2_Exp, ls_Y2_Exp) //必须先设置位置信息
  649. lnv_Object.OF_SetRequestor(This,lnv_Band, ls_Type, ls_Name)
  650. IF ib_Child Then
  651. IF ( lnv_Object.OF_GetTextRect_X1()+30)>il_x2 Then //显示的内容超过子数据窗口的显示范围
  652. Continue
  653. END IF
  654. END IF
  655. lnv_Band.OF_AddObject(lnv_Object)
  656. IF (ls_Y1_Exp<>'' OR ls_Y2_Exp<>'') AND is_Processing<>'1' AND is_Processing<>'4' Then
  657. lnv_Band.OF_SetDynamicRowInfo(TRUE)
  658. END IF
  659. Next
  660. //表头区边线设置的开始位置
  661. IF il_Header_BeginY=60000 Then
  662. il_Header_BeginY =0
  663. ELSE
  664. IF is_Units='1' Then
  665. il_Header_BeginY = PixelsToUnits(il_Header_BeginY, YPixelsToUnits!)
  666. ELSEIF is_Units='2' Then
  667. il_Header_BeginY = PixelsToUnits( inv_Api.OF_InchToPixels(il_Header_BeginY /1000), YPixelsToUnits!)
  668. ELSEIF is_Units='3' Then
  669. il_Header_BeginY = PixelsToUnits( inv_Api.OF_CMToPixels(il_Header_BeginY /1000), YPixelsToUnits!)
  670. END IF
  671. IF il_Header_BeginY<=0 AND is_Units<>'0' Then
  672. il_Header_BeginY+=65535
  673. END IF
  674. END IF
  675. //根据数据字段的位置,调整一下列标题的位置
  676. IF is_Processing="0" Then
  677. IF OF_ContaintBand("header") AND OF_ContaintBand("detail") Then
  678. lnv_Band = OF_GetBand("detail")
  679. IF lnv_Band.OF_GetVLinesCount()<3 Then //如果有线条,则按线条来处理位置,不自动调整
  680. OF_GetBand("header").OF_AdjustPosition(lnv_Band)
  681. END IF
  682. END IF
  683. //ELSEIF is_Processing='1' OR is_Processing='4' Then
  684. // For li=1 To UpperBound(inv_Bands)
  685. // inv_Bands[li].OF_AdjustPosition()
  686. // Next
  687. END IF
  688. //把带区的最后一条横边线,复制到下一带区,作为上边线
  689. IF is_Processing<>'1' AND is_Processing<>'4' THEN
  690. For li=1 To UpperBound(inv_Bands)
  691. //如果当前带区没有横线, 则不需要复制了
  692. IF UpperBound(inv_Bands[li].inv_HLines)<=0 Then
  693. Continue
  694. END IF
  695. ls_Name = OF_GetNextBand(inv_Bands[li].OF_GetName() )
  696. IF Not OF_ContaintBand(ls_Name) Then
  697. COntinue
  698. END IF
  699. li_Y2 = inv_Bands[li].OF_GetBandHeight()
  700. lnv_Band = OF_GetBand(ls_Name)
  701. For lj=1 TO UpperBound(inv_Bands[li].inv_HLines)
  702. lnv_Line = inv_Bands[li].inv_HLines[lj]
  703. IF lnv_Line.IsClone=False AND (lnv_Line.Y1 +inv_Layout.ii_RowSpace)>li_Y2 Then
  704. lnv_Line2 = Create n_dw2xls_Line
  705. lnv_Line2.IsClone =TRUE
  706. lnv_Line2.OF_SetPosition(lnv_Line.X1, 0, lnv_Line.X2, 0,lnv_Line.X1_Exp,"",lnv_Line.X2_Exp,"" )
  707. lnv_Line2.OF_SetRequestor(This, lnv_Line.ObjType,lnv_Line.Name, TRUE )
  708. lnv_Band.OF_AddHLine(lnv_Line2)
  709. END IF
  710. Next
  711. //把下一带区的上边线,复制到上一带区作下边线
  712. For lj=1 To UpperBound(lnv_Band.inv_HLines)
  713. lnv_Line = lnv_Band.inv_HLines[lj]
  714. IF lnv_Line.IsClone=False AND (lnv_Line.Y1 -inv_Layout.ii_RowSpace)<=0 Then
  715. lnv_Line2 = Create n_dw2xls_Line
  716. lnv_Line2.IsClone =TRUE
  717. lnv_Line2.OF_SetPosition(lnv_Line.X1, li_Y2, lnv_Line.X2,li_Y2,lnv_Line.X1_Exp ,"",lnv_Line.X2_Exp,"" )
  718. lnv_Line2.OF_SetRequestor(This, lnv_Line.ObjType,lnv_Line.Name,TRUE )
  719. inv_Bands[li].OF_AddHLine(lnv_Line2)
  720. END IF
  721. Next
  722. Next
  723. END IF
  724. OF_GetRowInDetail()
  725. OF_GetSparse()
  726. Return 1
  727. end function
  728. public function time of_getitemtime (readonly long al_row, readonly string as_name);IF al_Row<=0 OR al_Row>il_RowCount Then
  729. Return 00:00:00
  730. END IF
  731. Choose Case ipo_Type
  732. Case DataWindow!
  733. Return idw_Requestor.GetItemTime(al_Row,as_Name)
  734. Case DataStore!
  735. Return ids_Requestor.GetItemTime(al_Row,as_Name)
  736. Case DataWindowChild!
  737. Return idwc_Requestor.GetItemTime(al_Row,as_Name)
  738. END CHOOSE
  739. Return Time(00:00:00)
  740. end function
  741. public function Boolean of_ischild ();Return ib_Child
  742. end function
  743. public function string of_evaluate (long al_row, string as_exp);/*----------------------------------------------------------------------------
  744. 求指定表达式的值
  745. 返回值是字符串类型
  746. 如果计算有错误,返回空值
  747. 应用示例:
  748. long l_sum
  749. int li_page,li_pagecount
  750. l_sum=long(of_getvalud("1+30+120",1))
  751. li_page=integer(of_getvale("page()",1))
  752. li_pagecount=integer(of_getvalue("pagecount()",1))
  753. ------------------------------------------------------------------------------*/
  754. String ls_ret
  755. Int li_Pos
  756. string ls_temp
  757. ls_temp = as_exp
  758. Try
  759. as_exp=Trim(as_exp)
  760. IF Left(as_exp,1)="'" AND Right(as_exp,1)="'" Then
  761. as_exp=Mid(as_exp,2,Len(as_exp) -2)
  762. ELSE
  763. IF Left(as_exp,1)='"' AND Right(as_exp,1)='"' Then
  764. as_exp=Mid(as_exp,2,Len(as_exp) -2)
  765. END IF
  766. END IF
  767. as_exp=OF_ReplaceAll(as_exp,"'",'"' ) //把单引号换成双引号
  768. ls_ret=OF_describe("Evaluate('"+as_exp+"', " +string(al_row)+ ")")
  769. IF ls_ret="?" OR ls_ret="!" THEN
  770. ls_ret=""
  771. END IF
  772. Catch(DWRuntimeError dwEr)
  773. MessageBox("OF_Evaluate Error" ,dwer.text+"~r~n~r~n"+ls_temp , Exclamation! )
  774. Return ""
  775. Catch(RunTimeError er)
  776. MessageBox("OF_Evaluate Error" ,er.text+"~r~n~r~n"+ls_temp, Exclamation! )
  777. Return ""
  778. END TRY
  779. Return ls_ret
  780. end function
  781. public subroutine of_getproperty (readonly string as_property, ref string as_value, ref string as_exp);long ll_pos
  782. as_Value = OF_Describe(as_Property)
  783. as_Exp=""
  784. IF as_Value <> "!" AND as_Value <> "?" and as_Value <> "" Then
  785. ll_pos = pos(lower(as_Value), "~t")
  786. IF ll_pos > 0 Then
  787. as_Exp = right(as_Value, len(as_Value) - ll_pos)
  788. IF right(as_Exp, 1) = "~"" Then
  789. as_Exp = Trim(left(as_Exp, len(as_Exp) - 1))
  790. End IF
  791. as_Value = left(as_Value, ll_pos - 1)
  792. IF left(as_Value, 1) = "~"" Then
  793. as_Value = right(as_Value, len(as_Value) - 1)
  794. End IF
  795. End IF
  796. as_Value = Trim(as_Value)
  797. else
  798. as_Value=""
  799. as_Exp=""
  800. End IF
  801. //如果表达式是一个数值,则为该表达式的值作为属性的具体值
  802. IF IsNumber(as_Exp) Then
  803. as_Value = as_Exp
  804. as_Exp =""
  805. End IF
  806. end subroutine
  807. public function long of_parsetoarray (string as_source, string as_delimiter, ref string as_array[]);long ll_DelLen, ll_Pos, ll_Count, ll_Start, ll_Length
  808. string ls_holder
  809. String ls_Temp[]
  810. as_array= ls_Temp //清空原数组
  811. //Check for NULL
  812. IF IsNull(as_source) or IsNull(as_delimiter) Then
  813. long ll_null
  814. SetNull(ll_null)
  815. Return ll_null
  816. End If
  817. //Check for at leat one entry
  818. If Trim (as_source) = '' Then
  819. Return 0
  820. End If
  821. //Get the length of the delimeter
  822. ll_DelLen = Len(as_Delimiter)
  823. ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter))
  824. //Only one entry was found
  825. if ll_Pos = 0 then
  826. as_Array[1] = as_source
  827. return 1
  828. end if
  829. //More than one entry was found - loop to get all of them
  830. ll_Count = 0
  831. ll_Start = 1
  832. Do While ll_Pos > 0
  833. //Set current entry
  834. ll_Length = ll_Pos - ll_Start
  835. ls_holder = Mid (as_source, ll_start, ll_length)
  836. // Update array and counter
  837. ll_Count ++
  838. as_Array[ll_Count] = ls_holder
  839. //Set the new starting position
  840. ll_Start = ll_Pos + ll_DelLen
  841. ll_Pos = Pos(Upper(as_source), Upper(as_Delimiter), ll_Start)
  842. Loop
  843. //Set last entry
  844. ls_holder = Mid (as_source, ll_start, Len (as_source))
  845. // Update array and counter if necessary
  846. if Len (ls_holder) > 0 then
  847. ll_count++
  848. as_Array[ll_Count] = ls_holder
  849. end if
  850. //Return the number of entries found
  851. Return ll_Count
  852. end function
  853. protected function long of_lastpos (string as_source, string as_target, long al_start);
  854. Long ll_Cnt, ll_Pos
  855. //Check for Null Parameters.
  856. IF IsNull(as_source) or IsNull(as_target) or IsNull(al_start) Then
  857. SetNull(ll_Cnt)
  858. Return ll_Cnt
  859. End If
  860. //Check for an empty string
  861. If Len(as_Source) = 0 Then
  862. Return 0
  863. End If
  864. // Check for the starting position, 0 means start at the end.
  865. If al_start=0 Then
  866. al_start=Len(as_Source)
  867. End If
  868. //Perform find
  869. For ll_Cnt = al_start to 1 Step -1
  870. ll_Pos = Pos(as_Source, as_Target, ll_Cnt)
  871. If ll_Pos = ll_Cnt Then
  872. //String was found
  873. Return ll_Cnt
  874. End If
  875. Next
  876. //String was not found
  877. Return 0
  878. end function
  879. protected function long of_lastpos (string as_source, string as_target);//不直接使用LastPos,是因为PB6.5版本不支持LastPos函数
  880. Return of_LastPos (as_source, as_target, Len(as_Source))
  881. end function
  882. public function long of_arraytostring (readonly string as_source[], readonly string as_delimiter, ref string as_ref_string);
  883. long ll_DelLen, ll_Pos, ll_Count, ll_ArrayUpBound
  884. string ls_holder
  885. boolean lb_EntryFound = False
  886. //Get the array size
  887. ll_ArrayUpBound = UpperBound(as_source[])
  888. //Check parameters
  889. IF IsNull(as_delimiter) or (Not ll_ArrayUpBound>0) Then
  890. Return -1
  891. End If
  892. //Reset the Reference string
  893. as_ref_string = ''
  894. For ll_Count = 1 to ll_ArrayUpBound
  895. //Do not include any entries that match an empty string
  896. If as_source[ll_Count] <> '' Then
  897. If Len(as_ref_string) = 0 Then
  898. //Initialize string
  899. as_ref_string = as_source[ll_Count]
  900. else
  901. //Concatenate to string
  902. as_ref_string = as_ref_string + as_delimiter + as_source[ll_Count]
  903. End If
  904. End If
  905. Next
  906. return 1
  907. end function
  908. public function string of_replaceall (readonly string as_oldstr, readonly string as_findstr, readonly string as_repstr);long ll_Pos,ll_F,ll_R
  909. String ls_Result
  910. ll_F=Len(as_FindStr)
  911. ll_R=Len(as_RepStr)
  912. ls_Result = as_OldStr
  913. ll_Pos=Pos(ls_Result ,as_FindStr )
  914. DO WHILE ll_Pos<>0
  915. ls_Result=Replace(ls_Result,ll_Pos,ll_F, as_RepStr)
  916. ll_Pos=Pos(ls_Result, as_FindStr,ll_Pos+ll_R)
  917. LOOP
  918. RETURN ls_Result
  919. end function
  920. public subroutine of_dataformat (ref string as_format, ref string as_exp, string as_coltype);long ll_pos
  921. long ll_cnt
  922. string ls_arr[]
  923. long ll_i
  924. IF Not IsValid(inv_Api) Then
  925. inv_Api = Create n_dw2xls_WinApi
  926. End IF
  927. as_Format = Trim(as_Format)
  928. IF Right(as_Format,1)=";" Then
  929. as_Format = Left(as_Format,Len(as_Format) -1)
  930. End IF
  931. ll_pos = pos(as_format, "@")
  932. IF ll_pos > 0 Then
  933. as_format = "[general]"
  934. End IF
  935. ll_pos = pos(lower(as_format), "[general]")
  936. Do While ll_pos > 0
  937. IF as_ColType = "date" Then
  938. as_format = Replace(as_format, ll_pos, 9, inv_Api.OF_Get_ShortDateFormat() )
  939. ELSEIF as_ColType = "datetime" Then
  940. as_format = Replace(as_format, ll_pos, 9, inv_Api.OF_Get_ShortDateFormat()+' ' + inv_Api.OF_Get_TimeFormat() )
  941. ELSEIF as_ColType = "time" Then
  942. as_format = Replace(as_format, ll_pos, 9, inv_Api.OF_Get_TimeFormat() )
  943. ELSEIF Left(as_ColType,8)="decimal(" Then
  944. ll_cnt = Long(Mid(as_ColType,9,Len(as_ColType) -9))
  945. IF ll_cnt>0 Then
  946. as_Format="0"+inv_Api.OF_Get_DecmialSeparator()+Fill("0", ll_cnt)
  947. Else
  948. as_Format= "0"
  949. END IF
  950. ELSEIF as_ColType="decimal" Then //没有小位数, 则缺省为2位(实际要取控制面板的小数位置)
  951. as_Format= inv_Api.OF_Get_DecimalFormat()
  952. Else
  953. as_format = Replace(as_format, ll_pos, 9, "@")
  954. End IF
  955. ll_pos = pos(lower(as_format), "[general]")
  956. Loop
  957. ll_pos = pos(lower(as_format), "[currency]")
  958. Do While ll_pos > 0
  959. as_format = Replace(as_format, ll_pos, 10, inv_Api.OF_Get_CurrentFormat() )
  960. ll_pos = pos(lower(as_format), "[currency]")
  961. Loop
  962. ll_pos = pos(lower(as_format), "[longdate]")
  963. Do While ll_pos > 0
  964. as_format = Replace(as_format, ll_pos, 11, inv_Api.OF_Get_LongDateFormat() )
  965. ll_pos = pos(lower(as_format), "[longdate]")
  966. Loop
  967. ll_pos = pos(lower(as_format), "[shortdate]")
  968. Do While ll_pos > 0
  969. as_format = Replace(as_format, ll_pos, 11, inv_Api.OF_Get_ShortDateFormat() )
  970. ll_pos = pos(lower(as_format), "[shortdate]")
  971. Loop
  972. ll_pos = pos(lower(as_format), "[date]")
  973. Do While ll_pos > 0
  974. as_format = Replace(as_format, ll_pos, 6, inv_Api.OF_Get_ShortDateFormat() )
  975. ll_pos = pos(lower(as_format), "[date]")
  976. Loop
  977. ll_pos = pos(lower(as_format), "[time]")
  978. Do While ll_pos > 0
  979. as_format = Replace(as_format, ll_pos, 6, inv_Api.OF_Get_TimeFormat() )
  980. ll_pos = pos(lower(as_format), "[time]")
  981. Loop
  982. as_format = of_replaceAll(as_format, "'", "~"")
  983. as_format =of_replaceAll(as_format, "@", "General")
  984. IF pos(as_format, ";") > 0 Then
  985. ll_cnt = of_parsetoarray(as_format, ";", ls_arr)
  986. as_format =""
  987. IF ll_cnt > 3 Then
  988. ll_cnt = 3
  989. End IF
  990. For ll_i= 1 To ll_cnt
  991. IF ll_i=1 Then
  992. as_format=ls_arr[ll_i]
  993. ELSE
  994. as_format+=";"+ls_arr[ll_i]
  995. END IF
  996. Next
  997. End IF
  998. ll_pos = pos(lower(as_format), "~t")
  999. IF ll_pos > 0 Then
  1000. as_exp = right(as_format, len(as_format) - ll_pos)
  1001. IF right(as_exp, 1) = "~"" Then
  1002. as_exp =Trim(left(as_exp, len(as_exp) - 1))
  1003. End IF
  1004. as_format = left(as_format, ll_pos - 1)
  1005. IF left(as_format, 1) = "~"" Then
  1006. as_format = right(as_format, len(as_format) - 1)
  1007. End IF
  1008. End IF
  1009. end subroutine
  1010. public function long of_findgroupchange (readonly long al_row, readonly integer ai_level);Choose Case ipo_Type
  1011. Case DataWindow!
  1012. Return idw_Requestor.FindGroupChange(al_Row, ai_Level )
  1013. Case DataStore!
  1014. Return ids_Requestor.FindGroupChange(al_Row, ai_Level )
  1015. Case DataWindowChild!
  1016. Return idwc_Requestor.FindGroupChange(al_Row, ai_Level )
  1017. END CHOOSE
  1018. Return 0
  1019. end function
  1020. public subroutine of_getrowindetail ();Long li_Pos ,li_Pos2, li_Count
  1021. Long li, li_RowInDetail
  1022. String ls_Syntax, ls_Name, ls_Temp
  1023. n_dw2xls_Band lnv_Band
  1024. //如果数据窗口是N-UP类型,需要作以下处理
  1025. ii_Rows_Per_Detail = Long(OF_Describe("datawindow.Rows_Per_Detail"))
  1026. IF ii_Rows_Per_Detail<=1 Then
  1027. ii_Rows_Per_Detail=1
  1028. Return
  1029. END IF
  1030. // 修改为支持非Detail区的列对象也使用 row_in_detail 2011/10/08
  1031. //IF Not OF_ContaintBand("detail") Then
  1032. // RETURN
  1033. //END IF
  1034. //lnv_Band = OF_GetBand("detail")
  1035. //虽然Column对象的Attributes属性里面包括为Row_In_Detail,但Describe无法读出来,所以需要通过分析语法或获得
  1036. ls_Syntax=OF_Describe("datawindow.syntax")
  1037. li_Pos=Pos(ls_Syntax,"column(")
  1038. Do While li_Pos>0
  1039. li_Pos2=Pos(ls_Syntax,"column(",li_Pos+5)
  1040. IF li_Pos2=0 Then
  1041. li_Count=1024
  1042. ELSE
  1043. li_Count=li_Pos2 - li_Pos -1
  1044. END IF
  1045. //读出该Column对象的语法
  1046. ls_Temp=Mid(ls_Syntax,li_Pos ,li_Count)
  1047. li_Pos=Pos(ls_Temp,"row_in_detail=")
  1048. IF li_Pos<=0 Then
  1049. li_Pos=li_Pos2
  1050. Continue
  1051. END IF
  1052. li_Pos+=Len("row_in_detail=")
  1053. li_Count=Pos(ls_Temp," ",li_Pos+1) -li_Pos
  1054. li_RowInDetail=Long(Mid(ls_Temp,li_Pos,li_Count) ) //取得Row_In_Detail的值
  1055. IF li_RowInDetail>1 Then
  1056. //取得对象名称
  1057. li_Pos=Pos(ls_Temp,"name=")+Len("name=")
  1058. li_Count=Pos(ls_Temp," ",li_Pos+1) -li_Pos
  1059. ls_Name=Lower(Trim(Mid(ls_Temp,li_Pos,li_Count) ))
  1060. lnv_Band = OF_GetBand(OF_Describe(ls_Name+".Band") )
  1061. For li=1 To UpperBound(lnv_Band.inv_Objects)
  1062. IF lnv_Band.inv_Objects[li].Name=ls_Name Then
  1063. lnv_Band.inv_Objects[li].RowInDetail = li_RowInDetail
  1064. Exit
  1065. END IF
  1066. Next
  1067. END IF
  1068. li_Pos=li_Pos2
  1069. Loop
  1070. end subroutine
  1071. public subroutine of_getsparse ();Long li , lj,li_Count
  1072. String ls_Syntax, ls_Objects[]
  1073. n_dw2xls_Band lnv_Band
  1074. n_dw2xls_Object lnv_PriorSparseObject
  1075. IF Not inv_Progress.ib_ProcessSparse Then Return
  1076. ls_Syntax=OF_Describe("datawindow.sparse")
  1077. IF ls_Syntax="" Then
  1078. Return
  1079. END IF
  1080. IF Not OF_ContaintBand("detail") Then
  1081. RETURN
  1082. END IF
  1083. lnv_Band = OF_GetBand("detail")
  1084. li_Count=OF_ParseToArray(ls_Syntax,"~t",ls_Objects)
  1085. For li=1 To li_Count
  1086. For lj=1 To UpperBound(lnv_Band.inv_Objects)
  1087. IF lnv_Band.inv_Objects[lj].Name = ls_Objects[li] Then
  1088. lnv_Band.inv_Objects[lj].IsSparse =TRUE
  1089. IF IsValid(lnv_PriorSparseObject) Then
  1090. lnv_Band.inv_Objects[lj].inv_PriorSparseObject = lnv_PriorSparseObject
  1091. END IF
  1092. lnv_PriorSparseObject = lnv_Band.inv_Objects[lj]
  1093. EXIT
  1094. END IF
  1095. Next
  1096. Next
  1097. end subroutine
  1098. public function string of_getnextband (readonly string as_name);//取指定带区名称的下一个带区
  1099. Int li
  1100. String ls_Name
  1101. IF as_Name="header" Then
  1102. For li=1 TO ii_GroupLevels
  1103. IF OF_ContaintBand("header."+String(li)) Then
  1104. ls_Name = "header."+String(li)
  1105. Exit
  1106. END IF
  1107. Next
  1108. IF ls_Name="" Then
  1109. ls_Name="detail"
  1110. END IF
  1111. ELSEIF as_Name="detail" Then
  1112. For li=ii_GroupLevels TO 1 Step -1
  1113. IF OF_ContaintBand("trailer."+String(li)) Then
  1114. ls_Name = "trailer."+String(li)
  1115. Exit
  1116. END IF
  1117. Next
  1118. IF ls_Name="" Then
  1119. ls_Name="summary"
  1120. END IF
  1121. ELSEIF as_Name="summary" Then
  1122. ls_Name="footer"
  1123. ELSEIF as_Name="footer" Then
  1124. ls_Name=""
  1125. ELSE
  1126. END IF
  1127. Return ls_Name
  1128. end function
  1129. public subroutine of_setrow (long al_row);Choose Case ipo_Type
  1130. Case DataWindow!
  1131. idw_Requestor.SetRow(al_Row)
  1132. Case DataStore!
  1133. ids_Requestor.SetRow(al_Row)
  1134. Case DataWindowChild!
  1135. idwc_Requestor.SetRow(al_Row)
  1136. END CHOOSE
  1137. end subroutine
  1138. public function n_dw2xls_layout of_getlayout ();Return inv_Layout
  1139. end function
  1140. public subroutine of_registcolumninfo ();Int li
  1141. IF ib_Child Then
  1142. Return
  1143. END IF
  1144. OF_RegistColumnInfo_1()
  1145. IF inv_Layout.il_first_x1<inv_Layout.il_last_x2 AND inv_Layout.il_first_x1>0 Then
  1146. inv_Layout.OF_RegistObject(inv_Layout.il_first_x1,TRUE)
  1147. END IF
  1148. IF inv_Layout.il_last_x2>0 Then
  1149. inv_Layout.OF_RegistObject(inv_Layout.il_last_x2,FALSE)
  1150. END IF
  1151. //第二步,注册有边框的对象
  1152. OF_RegistColumnInfo_2()
  1153. //第三步 注册右对齐的对象
  1154. OF_RegistColumnInfo_3()
  1155. //第四步,从整个数据窗口的对象布局,进一步判断和登记其它的对象
  1156. inv_Layout.of_RegistColumnInfo()
  1157. end subroutine
  1158. public subroutine of_getcolrowinfo ();Int li
  1159. IF ii_Rows_Per_Detail<=0 Then
  1160. ii_Rows_Per_Detail =1
  1161. END IF
  1162. For li =1 To UpperBound( inv_Bands)
  1163. inv_Bands[li].OF_GetColRowInfo()
  1164. Next
  1165. For li =1 To UpperBound( inv_Bands)
  1166. inv_Bands[li].OF_SetCellBorder()
  1167. inv_Bands[li].OF_CalcPictureOffset()
  1168. IF ( inv_Layout.OF_IsNested()=False OR inv_Layout.OF_RowCount()=1) OR ib_Child=False Then
  1169. IF inv_Bands[li].OF_GetName()="detail" Then
  1170. inv_Layout.OF_IncreaseProgress_Data(Ceiling(OF_RowCount() /ii_Rows_Per_Detail ) )
  1171. ELSE
  1172. IF Pos(inv_Bands[li].OF_GetName(),".")=0 Then
  1173. inv_Layout.OF_IncreaseProgress_Data(1)
  1174. END IF
  1175. END IF
  1176. END IF
  1177. Next
  1178. end subroutine
  1179. public function Long of_getbkcolor ();Return il_BKColor
  1180. end function
  1181. public function string of_gettext (readonly long al_row, readonly string as_name, string as_coltype, readonly string as_format);Any Data
  1182. String ls_Result
  1183. IF as_ColType="char" Then
  1184. Data=OF_GetItemString(al_Row,as_Name)
  1185. Return Data
  1186. ELSEIF as_ColType="datetime" Then
  1187. Data =OF_GetItemDateTime(al_Row,as_Name)
  1188. ELSEIF as_ColType="date" Then
  1189. Data = OF_GetItemDate(al_Row,as_Name)
  1190. ELSEIF as_ColType="time" THEN
  1191. Data=OF_GetItemTime(al_Row,as_Name)
  1192. ELSE
  1193. Data=OF_GetItemNumber(al_Row,as_Name)
  1194. END IF
  1195. IF IsNull(Data) Then
  1196. Return ""
  1197. ELSE
  1198. IF Pos(as_Format,"@")>0 OR Pos(Lower(as_Format),"general")>0 Then
  1199. ls_Result = String(Data)
  1200. ELSE
  1201. ls_Result= String(Data, as_Format)
  1202. IF ls_Result="" Then
  1203. ls_Result =String(Data)
  1204. END IF
  1205. END IF
  1206. END IF
  1207. Return ls_Result
  1208. end function
  1209. public function integer of_setrequestor (powerobject apo, ref n_dw2xls_progress anv_progress);IF Not IsValid(apo) Then
  1210. Return -1
  1211. END IF
  1212. IF apo.TypeOF() <>DataWindow! AND &
  1213. apo.TypeOF() <> DataStore! AND &
  1214. apo.TypeOF() <> DataWindowChild! Then
  1215. Return -1
  1216. END IF
  1217. IF IsValid(inv_Layout) Then
  1218. Destroy inv_Layout
  1219. END IF
  1220. IF Not IsValid(anv_Progress) Then
  1221. anv_Progress =Create n_dw2xls_Progress
  1222. END IF
  1223. inv_Layout =Create n_dw2xls_Layout
  1224. IF OF_SetRequestor(apo,anv_Progress, inv_Layout ) <>1 Then
  1225. Destroy inv_Layout
  1226. Return -1
  1227. END IF
  1228. OF_RegistColumnInfo() //登记列的位置
  1229. inv_Layout.OF_GetColumnInfo() //得到各个列的起止位置
  1230. OF_GetColRowInfo() //判断各个对象输出的行列位置
  1231. OF_UpdateColumnInfo() //如果原来登记列的宽度 ,不能完整显示文本对象,则更新列的宽度,使期可以完整显示
  1232. Return 1
  1233. end function
  1234. private function integer of_setrequestor (powerobject apo, ref n_dw2xls_progress anv_progress, ref n_dw2xls_layout anv_layout);String ls_DataObject
  1235. Blob lblob_State
  1236. ipo_Type = apo.TypeOF()
  1237. Choose Case ipo_Type
  1238. Case DataWindow!
  1239. idw_Requestor = apo
  1240. il_RowCount = idw_Requestor.RowCount()
  1241. Case DataStore!
  1242. ids_Requestor = apo
  1243. il_RowCount = ids_Requestor.RowCount()
  1244. Case DataWindowChild!
  1245. idwc_Requestor = apo
  1246. il_RowCount = idwc_Requestor.RowCount()
  1247. Case Else
  1248. Return -1
  1249. END CHOOSE
  1250. //0 - (Default) Form, group, n-up, or tabular
  1251. //1 - Grid
  1252. //2 - Label
  1253. //3 - Graph
  1254. //4 - Crosstab
  1255. //5 - Composite
  1256. //6 - OLE
  1257. //7 - RichText
  1258. //8 - TreeView
  1259. //9 - TreeView with Grid
  1260. is_Processing = OF_Describe("DataWindow.Processing")
  1261. IF is_Processing='2' OR Long(is_Processing)>5 Then
  1262. Return -1
  1263. END IF
  1264. IF OF_Describe("DataWindow.Nested")="yes" Then
  1265. ib_Nested =TRUE
  1266. IF Not ib_Child Then //主数据窗口对象是否Nested 类型的
  1267. anv_Layout.OF_SetNested(TRUE )
  1268. END IF
  1269. END IF
  1270. IF Not ib_Child Then //主数据窗口的记录数
  1271. anv_Layout.OF_SetRowCount(il_RowCount)
  1272. //判断是否PSR文件
  1273. IF ipo_Type=DataWindow! Then
  1274. ls_DataObject = idw_Requestor.DataObject
  1275. ELSEIF ipo_Type=DataStore! Then
  1276. ls_DataObject = ids_Requestor.DataObject
  1277. END IF
  1278. END IF
  1279. inv_Progress = anv_progress
  1280. inv_Layout=anv_Layout
  1281. of_GetDWInfo()
  1282. IF Of_GetObjects() <>1 Then
  1283. Return -1
  1284. END IF
  1285. Return 1
  1286. end function
  1287. public function Boolean of_isdetail_begin ();Return ib_Detail_Begin
  1288. end function
  1289. public subroutine of_groupcalc ();Choose Case ipo_Type
  1290. Case DataWindow!
  1291. idw_Requestor.GroupCalc()
  1292. Case DataStore!
  1293. ids_Requestor.GroupCalc()
  1294. Case DataWindowChild!
  1295. idwc_Requestor.GroupCalc()
  1296. END CHOOSE
  1297. end subroutine
  1298. public function string of_getheader_beginband ();Return is_Header_BeginBand
  1299. end function
  1300. public function Boolean of_checkoutpictures ();Return inv_Layout.OF_CheckWritePictures()
  1301. end function
  1302. public function integer of_clipboard (readonly string as_name);Choose Case ipo_Type
  1303. Case DataWindow!
  1304. Return idw_Requestor.Clipboard(as_name)
  1305. Case DataStore!
  1306. Return ids_Requestor.Clipboard(as_name)
  1307. Case DataWindowChild!
  1308. Datastore lds
  1309. Int li_Result
  1310. lds =Create Datastore
  1311. lds.Create(idwc_Requestor.Describe("DataWindow.Syntax"))
  1312. li_Result= lds.Clipboard(as_name)
  1313. Destroy lds
  1314. Return li_Result
  1315. END CHOOSE
  1316. Return -1
  1317. end function
  1318. public subroutine of_setwinapi (n_dw2xls_winapi anv_api);inv_Api = anv_Api
  1319. end subroutine
  1320. public function n_dw2xls_winapi of_getwinapi ();IF Not IsValid(inv_Api) Then
  1321. inv_Api = Create n_dw2xls_winapi
  1322. END IF
  1323. Return inv_Api
  1324. end function
  1325. public function Boolean of_iscancel ();IF IsValid(inv_Progress) Then
  1326. Return inv_Progress.ib_Cancel
  1327. END IF
  1328. Return False
  1329. end function
  1330. public function Boolean of_isdatawindowchild ();Return ipo_Type=DataWindowChild!
  1331. end function
  1332. public function boolean of_iswritepictures ();IF IsValid(inv_Progress) Then
  1333. Return inv_Progress.ib_WritePictures
  1334. END IF
  1335. Return False
  1336. end function
  1337. public function boolean of_iswritebkcolor ();IF IsValid(inv_Progress) Then
  1338. Return inv_Progress.ib_WriteBKColor
  1339. END IF
  1340. RETURN FALSE
  1341. end function
  1342. public subroutine of_updatecolumninfo ();Int li
  1343. For li =1 To UpperBound( inv_Bands)
  1344. inv_Bands[li].OF_UpdateColumnInfo()
  1345. Next
  1346. inv_Layout.OF_UpdateColumnInfo()
  1347. end subroutine
  1348. public subroutine of_write_printsetting (readonly unsignedlong al_hsheet);Double ld_Margin_Left, ld_Margin_Top, ld_Margin_Right ,ld_Margin_Bottom
  1349. Int li_PaperSize ,li_Copies ,li_Scale ,li_PrintColors ,li_Orientation
  1350. ld_Margin_Left =Long(OF_Describe("DataWindow.Print.Margin.Left"))
  1351. ld_Margin_Right = Long(OF_Describe("DataWindow.Print.Margin.Right"))
  1352. ld_Margin_Top = Long(OF_Describe("DataWindow.Print.Margin.Top"))
  1353. ld_Margin_Bottom = Long(OF_Describe("DataWindow.Print.Margin.Bottom"))
  1354. IF is_Units='0' Then
  1355. ld_Margin_Left = inv_Api.OF_PixelsToInch( UnitsToPixels(ld_Margin_Left, XUnitsToPixels!) )
  1356. ld_Margin_Right = inv_Api.OF_PixelsToInch( UnitsToPixels(ld_Margin_Right, XUnitsToPixels!) )
  1357. ld_Margin_Top = inv_Api.OF_PixelsToInch( UnitsToPixels(ld_Margin_Top, YUnitsToPixels!) )
  1358. ld_Margin_Bottom = inv_Api.OF_PixelsToInch( UnitsToPixels(ld_Margin_Bottom, YUnitsToPixels!) )
  1359. ELSEIF is_Units='1' Then
  1360. ld_Margin_Left = inv_Api.OF_PixelsToInch( ld_Margin_Left )
  1361. ld_Margin_Right = inv_Api.OF_PixelsToInch( ld_Margin_Right )
  1362. ld_Margin_Top = inv_Api.OF_PixelsToInch( ld_Margin_Top )
  1363. ld_Margin_Bottom = inv_Api.OF_PixelsToInch( ld_Margin_Bottom )
  1364. ELSEIF is_Units='2' Then
  1365. ld_Margin_Left = ld_Margin_Left /1000
  1366. ld_Margin_Right = ld_Margin_Right /1000
  1367. ld_Margin_Top = ld_Margin_Top /1000
  1368. ld_Margin_Bottom = ld_Margin_Bottom /1000
  1369. ELSEIF is_Units='3' Then
  1370. ld_Margin_Left = inv_Api.OF_CmToInch( ld_Margin_Left /1000 )
  1371. ld_Margin_Right = inv_Api.OF_CmToInch( ld_Margin_Right /1000)
  1372. ld_Margin_Top = inv_Api.OF_CmToInch( ld_Margin_Top/1000 )
  1373. ld_Margin_Bottom = inv_Api.OF_CmToInch( ld_Margin_Bottom/1000 )
  1374. END IF
  1375. li_PaperSize = Long(OF_Describe("DataWindow.Print.Paper.Size"))
  1376. li_Copies = Long(OF_Describe("DataWindow.Print.Copies"))
  1377. li_Scale = Long(OF_Describe("DataWindow.Print.Scale"))
  1378. IF li_Scale=0 Then
  1379. li_Scale = Long(OF_Describe("DataWindow.Zoom"))
  1380. END IF
  1381. IF li_Scale<10 AND li_Scale>0 Then
  1382. li_Scale =10
  1383. ELSEIF li_Scale>400 Then
  1384. li_Scale =400
  1385. END IF
  1386. li_Orientation= Long(OF_Describe("DataWindow.Print.Orientation"))
  1387. IF OF_Describe("DataWindow.Print.Color")='1' Then
  1388. li_PrintColors =1
  1389. ELSE
  1390. li_PrintColors =0
  1391. END IF
  1392. inv_Api.SetMargin(al_hSheet, ld_Margin_Left, ld_Margin_Right, ld_Margin_Top, ld_Margin_Bottom)
  1393. inv_Api.SetPaperSize(al_hSheet, li_PaperSize)
  1394. inv_Api.SetPrintScale(al_hSheet, li_Scale)
  1395. inv_Api.SetPrintCopies(al_hSheet, li_Copies)
  1396. inv_Api.SetOrientation(al_hSheet, li_Orientation)
  1397. inv_Api.SetPrintColor(al_hSheet, li_PrintColors)
  1398. end subroutine
  1399. public function double of_getitemnumber (readonly long al_row, readonly integer ai_column);IF al_Row<=0 OR al_Row>il_RowCount Then
  1400. Return 0
  1401. END IF
  1402. Choose Case ipo_Type
  1403. Case DataWindow!
  1404. Return idw_Requestor.Object.Data[al_Row, ai_Column]
  1405. Case DataStore!
  1406. Return ids_Requestor.Object.Data[al_Row, ai_Column]
  1407. Case DataWindowChild!
  1408. Return idwc_Requestor.GetItemNumber(al_Row,ai_Column)
  1409. END CHOOSE
  1410. Return 0
  1411. end function
  1412. public function string of_getitemstring (readonly long al_row, readonly integer ai_column);IF al_Row<=0 OR al_Row>il_RowCount Then
  1413. Return""
  1414. END IF
  1415. Choose Case ipo_Type
  1416. Case DataWindow!
  1417. Return idw_Requestor.Object.Data[al_Row, ai_Column]
  1418. Case DataStore!
  1419. Return ids_Requestor.Object.Data[al_Row, ai_Column]
  1420. Case DataWindowChild!
  1421. Return idwc_Requestor.GetItemString(al_Row,ai_Column)
  1422. END CHOOSE
  1423. Return ""
  1424. end function
  1425. public function datetime of_getitemdatetime (readonly long al_row, readonly integer ai_column);
  1426. IF al_Row<=0 OR al_Row>il_RowCount Then
  1427. Return DateTime(1900-01-01,00:00:00)
  1428. END IF
  1429. Choose Case ipo_Type
  1430. Case DataWindow!
  1431. Return idw_Requestor.Object.Data[al_Row,ai_Column]
  1432. Case DataStore!
  1433. Return ids_Requestor.Object.Data[al_Row,ai_Column]
  1434. Case DataWindowChild!
  1435. Return idwc_Requestor.GetItemDateTime(al_Row,ai_Column)
  1436. END CHOOSE
  1437. Return DateTime(1900-01-01,00:00:00)
  1438. end function
  1439. public function date of_getitemdate (readonly long al_row, readonly integer ai_column);IF al_Row<=0 OR al_Row>il_RowCount Then
  1440. Return 1900-01-01
  1441. END IF
  1442. Choose Case ipo_Type
  1443. Case DataWindow!
  1444. Return idw_Requestor.Object.Data[al_Row,ai_Column]
  1445. Case DataStore!
  1446. Return ids_Requestor.Object.Data[al_Row,ai_Column]
  1447. Case DataWindowChild!
  1448. Return idwc_Requestor.GetItemDate(al_Row,ai_Column)
  1449. END CHOOSE
  1450. Return 1900-01-01
  1451. end function
  1452. public function time of_getitemtime (readonly long al_row, readonly integer ai_column);IF al_Row<=0 OR al_Row>il_RowCount Then
  1453. Return 00:00:00
  1454. END IF
  1455. Choose Case ipo_Type
  1456. Case DataWindow!
  1457. Return idw_Requestor.Object.Data[al_Row,ai_Column]
  1458. Case DataStore!
  1459. Return ids_Requestor.Object.Data[al_Row,ai_Column]
  1460. Case DataWindowChild!
  1461. Return idwc_Requestor.GetItemTime(al_Row,ai_Column)
  1462. END CHOOSE
  1463. Return 00:00:00
  1464. end function
  1465. public subroutine of_addexpression (ref string as_exp);Int li,li_cnt
  1466. Boolean lb_Space //前面字符是否空格
  1467. Boolean lb_Str1, lb_Str2 //单引号和双引号
  1468. String ls_NewExp, ls_Opt
  1469. n_dw2xls_Expression lnv_Exp
  1470. //格式化表达式
  1471. as_Exp = Trim(as_Exp)
  1472. IF Left(as_exp,1)="'" AND Right(as_exp,1)="'" Then
  1473. as_exp=Mid(as_exp,2,Len(as_exp) -2)
  1474. ELSE
  1475. IF Left(as_exp,1)='"' AND Right(as_exp,1)='"' Then
  1476. as_exp=Mid(as_exp,2,Len(as_exp) -2)
  1477. END IF
  1478. END IF
  1479. as_exp=OF_ReplaceAll(as_exp,"'",'"' ) //把单引号换成双引号
  1480. li_cnt = Len(as_Exp)
  1481. For li=1 To li_cnt
  1482. ls_Opt = Mid(as_Exp,li,1)
  1483. IF lb_Space AND ls_Opt=" " Then
  1484. Continue
  1485. END IF
  1486. IF ls_Opt="'" Then
  1487. lb_Str1 =Not lb_Str1
  1488. lb_Space=False
  1489. ELSEIF ls_Opt='"' Then
  1490. lb_Str2 = Not lb_Str2
  1491. lb_Space=False
  1492. ELSE
  1493. IF ls_Opt=" " Then
  1494. lb_Space=TRUE
  1495. ELSE
  1496. lb_Space=False
  1497. END IF
  1498. END IF
  1499. IF lb_Str1=False AND lb_Str2=False AND lb_Space=False Then
  1500. ls_NewExp += Lower(ls_Opt)
  1501. ELSE
  1502. ls_NewExp +=ls_Opt
  1503. END IF
  1504. Next
  1505. IF ls_NewExp="" Then
  1506. as_Exp=""
  1507. Return
  1508. END IF
  1509. li_cnt = UpperBound(inv_Exps)
  1510. For li=1 To li_cnt
  1511. IF inv_Exps[li].Expression = ls_NewExp Then
  1512. as_Exp = ls_NewExp
  1513. Return
  1514. END IF
  1515. NEXT
  1516. lnv_Exp = Create n_dw2xls_Expression
  1517. lnv_Exp.Expression= ls_NewExp
  1518. inv_Exps[li_cnt+1] = lnv_Exp
  1519. as_Exp = ls_NewExp
  1520. end subroutine
  1521. public subroutine of_updateexpvalues (readonly long al_row);Int li ,lj,li_cnt
  1522. Long li_Row
  1523. String ls_Value
  1524. IF al_Row=il_LastExpUpdateRow Then
  1525. Return
  1526. END IF
  1527. il_LastExpUpdateRow =al_Row
  1528. li_cnt = UpperBound(inv_Exps)
  1529. For li=1 To li_cnt
  1530. For lj=1 TO ii_Rows_Per_Detail
  1531. li_Row = al_Row+ii_Rows_Per_Detail -1
  1532. IF li_Row<=il_RowCount Then
  1533. //改成直接Describe,避免重复对字符串进行格式化处理
  1534. //inv_Exps[li].is_Values[lj]=OF_Evaluate(li_Row, inv_Exps[li].Expression)
  1535. ls_Value=OF_describe("Evaluate('"+ inv_Exps[li].Expression+"', " +string(li_Row)+ ")")
  1536. IF ls_Value="!" OR ls_Value="?" Then
  1537. ls_Value=""
  1538. END IF
  1539. inv_Exps[li].is_Values[lj] =ls_Value
  1540. END IF
  1541. Next
  1542. Next
  1543. end subroutine
  1544. public function string of_getexpvalue (readonly string as_exp, readonly integer ai_rowindetail);Int li,li_cnt
  1545. String ls_Result
  1546. Try
  1547. li_cnt =UpperBound(inv_Exps)
  1548. For li=1 To li_cnt
  1549. IF inv_Exps[li].Expression= as_Exp Then
  1550. IF ai_RowInDetail<=UpperBound(inv_Exps[li].is_Values) Then
  1551. ls_Result= inv_Exps[li].is_Values[ai_RowInDetail]
  1552. END IF
  1553. Exit
  1554. END IF
  1555. Next
  1556. Catch(RunTimeError er)
  1557. ls_Result=""
  1558. END TRY
  1559. Return ls_Result
  1560. end function
  1561. public subroutine of_updatereport (readonly long al_row, readonly string as_name, ref n_dw2xls_requestor anv_report);String ls_Data,ls_Syntax
  1562. Any la_Args[]
  1563. String ls_ArgTypes[]
  1564. n_dw2xls_DataStore lds
  1565. DWObject dwo
  1566. ls_Data = OF_Describe(as_Name+".Band")
  1567. IF ls_Data="header" OR ls_Data="summary" OR ls_Data="footer" Then
  1568. Return
  1569. END IF
  1570. IF Not IsValid(anv_report) Then
  1571. Return
  1572. END IF
  1573. IF Not IsValid(anv_report.ids_Requestor) Then
  1574. Return
  1575. END IF
  1576. IF OF_GetChild(al_Row,as_Name,dwo)=1 Then
  1577. anv_report.ids_Requestor.Reset()
  1578. anv_report.il_RowCount =0
  1579. TRY
  1580. //anv_report.ids_Requestor.ImportString(dwo.Object.DataWindow.Data)
  1581. anv_report.ids_Requestor.Create(anv_report.ids_Requestor.Describe("DataWindow.Syntax")+"~r~n"+String(dwo.Object.DataWindow.Syntax.Data))
  1582. anv_Report.il_RowCount =anv_Report.ids_Requestor.RowCount()
  1583. IF anv_Report.il_RowCount=0 Then
  1584. IF anv_Report.ids_Requestor.Describe("DataWindow.Processing")='5' Then
  1585. anv_Report.ids_Requestor.InsertRow(0)
  1586. anv_Report.il_RowCount =1
  1587. END IF
  1588. END IF
  1589. anv_Report.idwo_Parent = dwo
  1590. anv_Report.ids_Requestor.GroupCalc()
  1591. anv_report.OF_UpdateNestReport()
  1592. anv_Report.ib_Detail_Begin =TRUE
  1593. Catch(RunTimeError er)
  1594. END TRY
  1595. ELSE
  1596. anv_report.ids_Requestor.Reset()
  1597. anv_report.il_RowCount =0
  1598. IF OF_GetArguments(al_Row, anv_report.ids_Requestor.Describe("DataWindow.Table.Arguments"), OF_Describe(as_Name+".Nest_Arguments"), la_Args ,ls_ArgTypes )>0 Then
  1599. anv_report.ids_Requestor.Dynamic OF_Retrieve(la_Args , ls_ArgTypes )
  1600. anv_report.il_RowCount =anv_report.ids_Requestor.RowCount()
  1601. END IF
  1602. IF anv_Report.il_RowCount=0 Then
  1603. IF anv_Report.ids_Requestor.Describe("DataWindow.Processing")='5' Then
  1604. anv_Report.ids_Requestor.InsertRow(0)
  1605. anv_Report.il_RowCount =1
  1606. END IF
  1607. END IF
  1608. anv_Report.ids_Requestor.GroupCalc()
  1609. anv_report.OF_UpdateNestReport()
  1610. anv_Report.ib_Detail_Begin =TRUE
  1611. END IF
  1612. end subroutine
  1613. public function Boolean of_isvalid_dwomaster ();Return IsValid(idwo_Parent)
  1614. end function
  1615. public function string of_getdisplayvalue (readonly long al_row, readonly integer ai_colid, readonly string as_name, readonly boolean ab_isclone, readonly string as_editstyle, readonly string as_coltype);Long li_Row
  1616. String ls_Value , ls_DataColumn, ls_DisplayColumn
  1617. DataWindowChild dwc
  1618. Try
  1619. IF ab_IsClone AND as_EditStyle="dddw" Then
  1620. Choose Case as_ColType
  1621. Case "char"
  1622. ls_Value = OF_GetItemString(al_Row,as_Name)
  1623. Case "date"
  1624. ls_Value = String(OF_GetItemDate(al_Row,as_Name))
  1625. Case "datetime"
  1626. ls_Value =String(OF_GetItemDateTime(al_Row,as_Name))
  1627. Case "time"
  1628. ls_Value = String(OF_GetItemTime(al_Row,as_Name))
  1629. Case Else
  1630. ls_Value =String(OF_GetItemNumber(al_Row,as_Name))
  1631. END CHOOSE
  1632. ls_DataColumn =OF_Describe(as_Name+".DDDW.DataColumn")
  1633. ls_DisplayColumn =OF_Describe(as_Name+".DDDW.DisplayColumn")
  1634. IF ls_Value<>"" AND IsNull(ls_Value)=False AND &
  1635. ls_DataColumn<>ls_DisplayColumn AND ls_DataColumn<>"" AND ls_DataColumn<>"!" Then
  1636. OF_GetChild(as_Name, dwc)
  1637. IF IsValid(dwc) Then
  1638. IF as_ColType="char" OR as_ColType="date" OR as_ColType="datetime" OR as_ColType="time" Then
  1639. li_Row = dwc.Find(ls_DataColumn+"='"+ls_Value+"' ",1,dwc.RowCount())
  1640. ELSE
  1641. li_Row = dwc.Find(ls_DataColumn+"="+ls_Value,1,dwc.RowCount())
  1642. END IF
  1643. IF li_Row>0 Then
  1644. ls_Value = dwc.Describe("Evaluate('"+ls_DisplayColumn+"',"+String(li_Row)+")")
  1645. END IF
  1646. END IF
  1647. END IF
  1648. ELSE
  1649. IF ai_ColID>0 Then
  1650. ls_Value= OF_Describe("Evaluate('LookUpDisplay(#"+String(ai_ColID)+") ', " +string(al_row)+ ")")
  1651. ELSE
  1652. ls_Value= OF_Describe("Evaluate('LookUpDisplay(#"+as_Name+") ', " +string(al_row)+ ")")
  1653. END IF
  1654. END IF
  1655. Catch(DWRuntimeError dwEr)
  1656. Messagebox('OF_GetDisplayValue Error',dwEr.text+"~r~n~r~nRow:"+String(al_Row)+" Name:"+as_Name ,Exclamation! )
  1657. Catch(RunTimeError er)
  1658. Messagebox('OF_GetDisplayValue Error',er.text+"~r~n~r~nRow:"+String(al_Row)+" Name:"+as_Name ,Exclamation! )
  1659. END TRY
  1660. Return ls_Value
  1661. end function
  1662. public function Integer of_getchild (string as_name, ref datawindowchild adwc);Int li_Result
  1663. li_Result =-1
  1664. Choose Case ipo_Type
  1665. Case DataWindow!
  1666. li_Result= idw_Requestor.GetChild(as_Name, adwc)
  1667. Case DataStore!
  1668. li_Result= ids_Requestor.GetChild(as_Name, adwc)
  1669. Case DataWindowChild!
  1670. li_Result= idwc_Requestor.GetChild(as_Name, adwc)
  1671. END CHOOSE
  1672. Return li_Result
  1673. end function
  1674. public function integer of_getchild (readonly long al_row, readonly string as_name, ref dwobject dwo);Int li_Result
  1675. li_Result =0
  1676. IF IsValid(idwo_Parent) Then
  1677. Try
  1678. Choose Case Lower(as_Name)
  1679. Case "dw_1"
  1680. dwo=idwo_Parent.Object.dw_1[al_row]
  1681. Case "dw_2"
  1682. dwo=idwo_Parent.Object.dw_2[al_row]
  1683. Case "dw_3"
  1684. dwo=idwo_Parent.Object.dw_3[al_row]
  1685. Case "dw_4"
  1686. dwo=idwo_Parent.Object.dw_4[al_row]
  1687. Case "dw_5"
  1688. dwo=idwo_Parent.Object.dw_5[al_row]
  1689. Case "dw_6"
  1690. dwo=idwo_Parent.Object.dw_6[al_row]
  1691. Case "dw_7"
  1692. dwo=idwo_Parent.Object.dw_7[al_row]
  1693. Case "dw_8"
  1694. dwo=idwo_Parent.Object.dw_8[al_row]
  1695. Case "dw_9"
  1696. dwo=idwo_Parent.Object.dw_9[al_row]
  1697. Case "dw_10"
  1698. dwo=idwo_Parent.Object.dw_10[al_row]
  1699. Case "dw_11"
  1700. dwo=idwo_Parent.Object.dw_11[al_row]
  1701. Case "dw_12"
  1702. dwo=idwo_Parent.Object.dw_12[al_row]
  1703. Case "dw_13"
  1704. dwo=idwo_Parent.Object.dw_13[al_row]
  1705. Case "dw_14"
  1706. dwo=idwo_Parent.Object.dw_14[al_row]
  1707. Case "dw_15"
  1708. dwo=idwo_Parent.Object.dw_15[al_row]
  1709. Case "dw_16"
  1710. dwo=idwo_Parent.Object.dw_16[al_row]
  1711. Case "dw_17"
  1712. dwo=idwo_Parent.Object.dw_17[al_row]
  1713. Case "dw_18"
  1714. dwo=idwo_Parent.Object.dw_18[al_row]
  1715. Case "dw_19"
  1716. dwo=idwo_Parent.Object.dw_19[al_row]
  1717. Case "dw_20"
  1718. dwo=idwo_Parent.Object.dw_20[al_row]
  1719. Case "dw_21"
  1720. dwo=idwo_Parent.Object.dw_21[al_row]
  1721. Case "dw_22"
  1722. dwo=idwo_Parent.Object.dw_22[al_row]
  1723. Case "dw_23"
  1724. dwo=idwo_Parent.Object.dw_23[al_row]
  1725. Case "dw_24"
  1726. dwo=idwo_Parent.Object.dw_24[al_row]
  1727. Case "dw_25"
  1728. dwo=idwo_Parent.Object.dw_25[al_row]
  1729. Case "dw_26"
  1730. dwo=idwo_Parent.Object.dw_26[al_row]
  1731. Case "dw_27"
  1732. dwo=idwo_Parent.Object.dw_27[al_row]
  1733. Case "dw_28"
  1734. dwo=idwo_Parent.Object.dw_28[al_row]
  1735. Case "dw_29"
  1736. dwo=idwo_Parent.Object.dw_29[al_row]
  1737. Case "dw_30"
  1738. dwo=idwo_Parent.Object.dw_30[al_row]
  1739. Case "dw_master"
  1740. dwo=idwo_Parent.Object.dw_master[al_row]
  1741. case "dw_main"
  1742. dwo=idwo_Parent.Object.dw_main[al_row]
  1743. Case "d_main"
  1744. dwo=idwo_Parent.Object.d_main[al_row]
  1745. END CHOOSE
  1746. Catch(RunTimeError er1)
  1747. li_Result = -1
  1748. END TRY
  1749. ELSEIF IsValid(idw_Requestor) Then
  1750. Try
  1751. Choose Case Lower(as_Name)
  1752. Case "dw_1"
  1753. dwo=idw_Requestor.Object.dw_1[al_row]
  1754. Case "dw_2"
  1755. dwo=idw_Requestor.Object.dw_2[al_row]
  1756. Case "dw_3"
  1757. dwo=idw_Requestor.Object.dw_3[al_row]
  1758. Case "dw_4"
  1759. dwo=idw_Requestor.Object.dw_4[al_row]
  1760. Case "dw_5"
  1761. dwo=idw_Requestor.Object.dw_5[al_row]
  1762. Case "dw_6"
  1763. dwo=idw_Requestor.Object.dw_6[al_row]
  1764. Case "dw_7"
  1765. dwo=idw_Requestor.Object.dw_7[al_row]
  1766. Case "dw_8"
  1767. dwo=idw_Requestor.Object.dw_8[al_row]
  1768. Case "dw_9"
  1769. dwo=idw_Requestor.Object.dw_9[al_row]
  1770. Case "dw_10"
  1771. dwo=idw_Requestor.Object.dw_10[al_row]
  1772. Case "dw_11"
  1773. dwo=idw_Requestor.Object.dw_11[al_row]
  1774. Case "dw_12"
  1775. dwo=idw_Requestor.Object.dw_12[al_row]
  1776. Case "dw_13"
  1777. dwo=idw_Requestor.Object.dw_13[al_row]
  1778. Case "dw_14"
  1779. dwo=idw_Requestor.Object.dw_14[al_row]
  1780. Case "dw_15"
  1781. dwo=idw_Requestor.Object.dw_15[al_row]
  1782. Case "dw_16"
  1783. dwo=idw_Requestor.Object.dw_16[al_row]
  1784. Case "dw_17"
  1785. dwo=idw_Requestor.Object.dw_17[al_row]
  1786. Case "dw_18"
  1787. dwo=idw_Requestor.Object.dw_18[al_row]
  1788. Case "dw_19"
  1789. dwo=idw_Requestor.Object.dw_19[al_row]
  1790. Case "dw_20"
  1791. dwo=idw_Requestor.Object.dw_20[al_row]
  1792. Case "dw_21"
  1793. dwo=idw_Requestor.Object.dw_21[al_row]
  1794. Case "dw_22"
  1795. dwo=idw_Requestor.Object.dw_22[al_row]
  1796. Case "dw_23"
  1797. dwo=idw_Requestor.Object.dw_23[al_row]
  1798. Case "dw_24"
  1799. dwo=idw_Requestor.Object.dw_24[al_row]
  1800. Case "dw_25"
  1801. dwo=idw_Requestor.Object.dw_25[al_row]
  1802. Case "dw_26"
  1803. dwo=idw_Requestor.Object.dw_26[al_row]
  1804. Case "dw_27"
  1805. dwo=idw_Requestor.Object.dw_27[al_row]
  1806. Case "dw_28"
  1807. dwo=idw_Requestor.Object.dw_28[al_row]
  1808. Case "dw_29"
  1809. dwo=idw_Requestor.Object.dw_29[al_row]
  1810. Case "dw_30"
  1811. dwo=idw_Requestor.Object.dw_30[al_row]
  1812. Case "dw_master"
  1813. dwo=idw_Requestor.Object.dw_master[al_row]
  1814. Case "dw_main"
  1815. dwo=idw_Requestor.Object.dw_main[al_row]
  1816. Case "d_main"
  1817. dwo=idw_Requestor.Object.d_main[al_row]
  1818. END CHOOSE
  1819. Catch(RunTimeError er2)
  1820. li_Result = -1
  1821. END TRY
  1822. ELSEIF IsValid(ids_Requestor) Then
  1823. Try
  1824. Choose Case Lower(as_Name)
  1825. Case "dw_1"
  1826. dwo=ids_Requestor.Object.dw_1[al_row]
  1827. Case "dw_2"
  1828. dwo=ids_Requestor.Object.dw_2[al_row]
  1829. Case "dw_3"
  1830. dwo=ids_Requestor.Object.dw_3[al_row]
  1831. Case "dw_4"
  1832. dwo=ids_Requestor.Object.dw_4[al_row]
  1833. Case "dw_5"
  1834. dwo=ids_Requestor.Object.dw_5[al_row]
  1835. Case "dw_6"
  1836. dwo=ids_Requestor.Object.dw_6[al_row]
  1837. Case "dw_7"
  1838. dwo=ids_Requestor.Object.dw_7[al_row]
  1839. Case "dw_8"
  1840. dwo=ids_Requestor.Object.dw_8[al_row]
  1841. Case "dw_9"
  1842. dwo=ids_Requestor.Object.dw_9[al_row]
  1843. Case "dw_10"
  1844. dwo=ids_Requestor.Object.dw_10[al_row]
  1845. Case "dw_11"
  1846. dwo=ids_Requestor.Object.dw_11[al_row]
  1847. Case "dw_12"
  1848. dwo=ids_Requestor.Object.dw_12[al_row]
  1849. Case "dw_13"
  1850. dwo=ids_Requestor.Object.dw_13[al_row]
  1851. Case "dw_14"
  1852. dwo=ids_Requestor.Object.dw_14[al_row]
  1853. Case "dw_15"
  1854. dwo=ids_Requestor.Object.dw_15[al_row]
  1855. Case "dw_16"
  1856. dwo=ids_Requestor.Object.dw_16[al_row]
  1857. Case "dw_17"
  1858. dwo=ids_Requestor.Object.dw_17[al_row]
  1859. Case "dw_18"
  1860. dwo=ids_Requestor.Object.dw_18[al_row]
  1861. Case "dw_19"
  1862. dwo=ids_Requestor.Object.dw_19[al_row]
  1863. Case "dw_20"
  1864. dwo=ids_Requestor.Object.dw_20[al_row]
  1865. Case "dw_21"
  1866. dwo=ids_Requestor.Object.dw_21[al_row]
  1867. Case "dw_22"
  1868. dwo=ids_Requestor.Object.dw_22[al_row]
  1869. Case "dw_23"
  1870. dwo=ids_Requestor.Object.dw_23[al_row]
  1871. Case "dw_24"
  1872. dwo=ids_Requestor.Object.dw_24[al_row]
  1873. Case "dw_25"
  1874. dwo=ids_Requestor.Object.dw_25[al_row]
  1875. Case "dw_26"
  1876. dwo=ids_Requestor.Object.dw_26[al_row]
  1877. Case "dw_27"
  1878. dwo=ids_Requestor.Object.dw_27[al_row]
  1879. Case "dw_28"
  1880. dwo=ids_Requestor.Object.dw_28[al_row]
  1881. Case "dw_29"
  1882. dwo=ids_Requestor.Object.dw_29[al_row]
  1883. Case "dw_30"
  1884. dwo=ids_Requestor.Object.dw_30[al_row]
  1885. Case "dw_master"
  1886. dwo=ids_Requestor.Object.dw_master[al_row]
  1887. Case "dw_main"
  1888. dwo=idw_Requestor.Object.dw_main[al_row]
  1889. Case "d_main"
  1890. dwo=idw_Requestor.Object.d_main[al_row]
  1891. END CHOOSE
  1892. Catch(RunTimeError er3)
  1893. li_Result = -1
  1894. END TRY
  1895. END IF
  1896. IF IsValid(dwo) AND li_Result=0 Then
  1897. li_Result=1
  1898. END IF
  1899. Return li_Result
  1900. end function
  1901. public function boolean of_isnested ();Return ib_Nested
  1902. end function
  1903. public subroutine of_updatenestreport ();Int li
  1904. For li=1 To UpperBound(inv_NestReports)
  1905. OF_UpdateReport(1,inv_NestReports[li].Name ,inv_NestReports[li].inv_Report )
  1906. Next
  1907. end subroutine
  1908. public subroutine of_registcolumninfo_1 ();Int li
  1909. //先取得对象的边线信息
  1910. For li=1 TO UpperBound(inv_Bands)
  1911. inv_Bands[li].OF_GetObjectBorderInfo()
  1912. Next
  1913. //第一步,先注册细节区的对象
  1914. IF OF_ContaintBand("detail") Then
  1915. OF_GetBand("detail").OF_RegistColumnInfo_1()
  1916. ELSEIF is_Processing<>"1" AND is_Processing<>"4" Then
  1917. For li=1 TO UpperBound(inv_Bands)
  1918. inv_Bands[li].OF_RegistColumnInfo_1()
  1919. Next
  1920. END IF
  1921. //处理子数据窗口
  1922. For li=1 To UpperBound(inv_ChildReports)
  1923. IF IsValid(inv_ChildReports[li].inv_Report) Then
  1924. inv_ChildReports[li].inv_Report.OF_RegistColumnInfo_1()
  1925. END IF
  1926. Next
  1927. For li=1 To UpperBound(inv_NestReports)
  1928. IF IsValid(inv_NestReports[li].inv_Report) Then
  1929. inv_NestReports[li].inv_Report.OF_RegistColumnInfo_1()
  1930. END IF
  1931. Next
  1932. end subroutine
  1933. public subroutine of_registcolumninfo_2 ();Int li
  1934. //第二步,注册有边框和向右对齐的对象
  1935. For li=1 TO UpperBound(inv_Bands)
  1936. inv_Bands[li].OF_RegistColumnInfo_2()
  1937. Next
  1938. //处理子数据窗口
  1939. For li=1 To UpperBound(inv_ChildReports)
  1940. IF IsValid(inv_ChildReports[li].inv_Report) Then
  1941. inv_ChildReports[li].inv_Report.OF_RegistColumnInfo_2()
  1942. END IF
  1943. Next
  1944. For li=1 To UpperBound(inv_NestReports)
  1945. IF IsValid(inv_NestReports[li].inv_Report) Then
  1946. inv_NestReports[li].inv_Report.OF_RegistColumnInfo_2()
  1947. END IF
  1948. Next
  1949. end subroutine
  1950. public subroutine of_registcolumninfo_3 ();Int li
  1951. //第二步,注册有边框和向右对齐的对象
  1952. For li=1 TO UpperBound(inv_Bands)
  1953. inv_Bands[li].OF_RegistColumnInfo_3()
  1954. Next
  1955. //处理子数据窗口
  1956. For li=1 To UpperBound(inv_ChildReports)
  1957. IF IsValid(inv_ChildReports[li].inv_Report) Then
  1958. inv_ChildReports[li].inv_Report.OF_RegistColumnInfo_3()
  1959. END IF
  1960. Next
  1961. For li=1 To UpperBound(inv_NestReports)
  1962. IF IsValid(inv_NestReports[li].inv_Report) Then
  1963. inv_NestReports[li].inv_Report.OF_RegistColumnInfo_3()
  1964. END IF
  1965. Next
  1966. end subroutine
  1967. public subroutine of_getobjectposition (readonly string as_band, readonly string as_type, readonly string as_name, ref long ai_x1, ref long ai_y1, ref long ai_x2, ref long ai_y2, ref string as_x1_exp, ref string as_y1_exp, ref string as_x2_exp, ref string as_y2_exp);Long li_Temp
  1968. Long li_Row
  1969. String ls_Value, ls_Exp
  1970. ai_x1 = 0
  1971. ai_y1=0
  1972. ai_x2=0
  1973. ai_y2=0
  1974. as_x1_exp=""
  1975. as_y1_exp=""
  1976. as_x2_exp=""
  1977. as_y2_exp=""
  1978. IF as_Band="summary" OR as_Band="footer" Then
  1979. li_Row =OF_RowCount()
  1980. ELSE
  1981. li_Row =1
  1982. END IF
  1983. Choose Case as_Type
  1984. Case "line"
  1985. OF_GetProperty(as_Name,"x1", ls_Value, ls_Exp)
  1986. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  1987. as_x1_exp=ls_Exp
  1988. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  1989. END IF
  1990. IF IsNumber(ls_Exp) Then
  1991. ai_x1= Long(ls_Exp)
  1992. ELSE
  1993. ai_x1 = Long(ls_Value)
  1994. END IF
  1995. OF_GetProperty(as_Name,"y1", ls_Value, ls_Exp)
  1996. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  1997. as_y1_exp=ls_Exp
  1998. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  1999. END IF
  2000. IF IsNumber(ls_Exp) Then
  2001. ai_y1 = Long(ls_Exp)
  2002. ELSE
  2003. ai_Y1 = Long(ls_Value)
  2004. END IF
  2005. OF_GetProperty(as_Name,"X2", ls_Value, ls_Exp)
  2006. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2007. as_x2_exp=ls_Exp
  2008. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2009. END IF
  2010. IF IsNumber(ls_Exp) Then
  2011. ai_x2 = Long(ls_Exp)
  2012. ELSE
  2013. ai_x2= Long(ls_Value)
  2014. END IF
  2015. OF_GetProperty(as_Name,"Y2", ls_Value, ls_Exp)
  2016. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2017. as_y2_exp=ls_Exp
  2018. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2019. END IF
  2020. IF IsNumber(ls_Exp) Then
  2021. ai_y2 = Long(ls_Exp)
  2022. ELSE
  2023. ai_Y2= Long(ls_Value)
  2024. END IF
  2025. IF ai_x1>ai_x2 Then
  2026. li_Temp = ai_x1
  2027. ai_x1 = ai_x2
  2028. ai_x2 =li_Temp
  2029. END IF
  2030. IF ai_y1>ai_y2 Then
  2031. li_Temp = ai_y1
  2032. ai_y1 = ai_y2
  2033. ai_y2 =li_Temp
  2034. END IF
  2035. Case Else
  2036. OF_GetProperty(as_Name,"x", ls_Value, ls_Exp)
  2037. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2038. as_x1_exp=ls_Exp
  2039. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2040. END IF
  2041. IF IsNumber(ls_Exp) Then
  2042. ai_x1 = Long(ls_Exp)
  2043. ELSE
  2044. ai_x1 = Long(ls_Value)
  2045. END IF
  2046. OF_GetProperty(as_Name,"y", ls_Value, ls_Exp)
  2047. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2048. as_y1_exp=ls_Exp
  2049. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2050. END IF
  2051. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2052. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2053. END IF
  2054. IF IsNumber(ls_exp) Then
  2055. ai_y1 = Long(ls_Exp)
  2056. ELSE
  2057. ai_Y1 = Long(ls_Value)
  2058. END IF
  2059. OF_GetProperty(as_Name,"Width", ls_Value, ls_Exp)
  2060. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2061. as_x2_exp=ls_Exp
  2062. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2063. END IF
  2064. IF IsNumber( ls_exp) Then
  2065. ai_x2 = ai_x1+ Long(ls_Exp)
  2066. ELSE
  2067. ai_x2=ai_x1+ Long(ls_Value)
  2068. END IF
  2069. OF_GetProperty(as_Name,"Height", ls_Value, ls_Exp)
  2070. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2071. as_y2_exp=ls_Exp
  2072. ls_Exp = OF_Evaluate(li_Row, ls_Exp)
  2073. END IF
  2074. IF IsNumber(ls_Exp) Then
  2075. ai_Y2=ai_Y1+ Long(ls_Exp)
  2076. ELSE
  2077. ai_y2 = ai_y1 + Long(ls_Value)
  2078. END IF
  2079. END CHOOSE
  2080. IF ai_x1<0 Then
  2081. ai_x1=0
  2082. END IF
  2083. IF ai_y1<0 Then
  2084. ai_y1=0
  2085. END IF
  2086. IF ai_x2 <0 Then
  2087. ai_x2 =0
  2088. END IF
  2089. IF ai_y2<0 Then
  2090. ai_y2=0
  2091. END IF
  2092. IF is_Units='1' Then
  2093. ai_x1 = PixelsToUnits(ai_X1, XPixelsToUnits!)
  2094. ai_x2 = PixelsToUnits(ai_x2, XPixelsToUnits!)
  2095. ai_y1 = PixelsToUnits(ai_y1, YPixelsToUnits!)
  2096. ai_y2 = PixelsToUnits(ai_y2, YPixelsToUnits!)
  2097. ELSEIF is_Units='2' Then
  2098. ai_x1 = PixelsToUnits(inv_Api.OF_InchToPixels(ai_X1/1000 ) , XPixelsToUnits!)
  2099. ai_x2 = PixelsToUnits(inv_Api.OF_InchToPixels(ai_x2/1000) , XPixelsToUnits!)
  2100. ai_y1 = PixelsToUnits(inv_Api.OF_InchToPixels(ai_y1 /1000 ) , YPixelsToUnits!)
  2101. ai_y2 = PixelsToUnits(inv_Api.OF_InchToPixels(ai_y2/1000 ), YPixelsToUnits!)
  2102. ELSEIF is_Units='3' Then
  2103. ai_x1 = PixelsToUnits(inv_Api.OF_CMToPixels(ai_X1 /1000), XPixelsToUnits!)
  2104. ai_x2 = PixelsToUnits(inv_Api.OF_CMToPixels(ai_x2 /1000 ), XPixelsToUnits!)
  2105. ai_y1 = PixelsToUnits(inv_Api.OF_CMToPixels(ai_y1 /1000 ), YPixelsToUnits!)
  2106. ai_y2 = PixelsToUnits(inv_Api.OF_CMToPixels(ai_y2 /1000 ), YPixelsToUnits!)
  2107. END IF
  2108. IF is_Units<>'0' Then
  2109. IF ai_x1<0 Then
  2110. ai_x1+=65536
  2111. END IF
  2112. IF ai_y1<0 Then
  2113. ai_y1+=65536
  2114. END IF
  2115. IF ai_x2 <0 Then
  2116. ai_x2 +=65536
  2117. END IF
  2118. IF ai_y2<0 Then
  2119. ai_y2+=65536
  2120. END IF
  2121. END IF
  2122. IF as_Band<>"detail" AND Pos(as_Band,".")<=0 Then
  2123. as_x1_exp=""
  2124. as_y1_exp=""
  2125. as_x2_exp=""
  2126. as_y2_exp=""
  2127. END IF
  2128. end subroutine
  2129. public function Long of_getbandheight (readonly string as_band);Long li_Height
  2130. li_Height = Long(OF_Describe("DataWindow."+as_Band+".Height"))
  2131. IF is_Units ='1' Then
  2132. li_Height = PixelsToUnits(li_Height ,YPixelsToUnits!)
  2133. ELSEIF is_Units='2' Then
  2134. li_Height = PixelsToUnits(inv_Api.OF_InchToPixels( li_Height) /1000,YPixelsToUnits!)
  2135. ELSEIF is_Units='3' Then
  2136. li_Height = PixelsToUnits(inv_Api. OF_CMToPixels( li_Height )/1000,YPixelsToUnits!)
  2137. END IF
  2138. IF li_Height<0 and is_Units<>'0' Then
  2139. li_Height+=65535
  2140. END IF
  2141. Return li_Height
  2142. end function
  2143. public function long of_getreport_x1 ();Return il_X
  2144. end function
  2145. public function Long of_getheader_beginy ();Return il_Header_BeginY
  2146. end function
  2147. public function Long of_getcontrolheight ();IF ipo_Type=DataWindow! Then
  2148. Return idw_Requestor.Height
  2149. ELSEIF ib_Child Then
  2150. Return il_Y2 - il_Y
  2151. ELSEIF is_Processing='3' Then
  2152. END IF
  2153. RETURN 0
  2154. end function
  2155. public function Long of_getcontrolwidth ();IF ipo_Type=DataWindow! Then
  2156. Return idw_Requestor.Width
  2157. ELSEIF ib_Child Then
  2158. Return il_X2 - il_X
  2159. END IF
  2160. RETURN 0
  2161. end function
  2162. public function Long of_getreport_x2 ();Return il_X2
  2163. end function
  2164. public function boolean of_initialreport (n_dw2xls_object anv_object, readonly long ai_x, readonly long ai_y, readonly long ai_x2, readonly long ai_y2);String ls_Name , ls_Band, ls_Data, ls_Syntax
  2165. Long li_Row , li_Result
  2166. Any la_Args[]
  2167. String ls_ArgTypes[]
  2168. String ls_Processing
  2169. n_dw2xls_DataStore lds
  2170. n_dw2xls_Requestor lnv_Report
  2171. DWObject dwo ,dwo2
  2172. DataWindowChild dwc
  2173. IF Not IsValid(anv_Object) Then
  2174. Return False
  2175. END IF
  2176. ls_Band =anv_Object.inv_Band.OF_GetName()
  2177. IF ls_Band="summary" OR ls_Band="footer" Then
  2178. li_Row =anv_Object.inv_Requestor.OF_RowCount()
  2179. ELSE
  2180. IF anv_Object.inv_Requestor.OF_RowCount() >0 Then
  2181. li_Row =1
  2182. END IF
  2183. END IF
  2184. ls_Name = anv_Object.Name
  2185. li_Result =0
  2186. IF OF_GetChild(ls_Name, dwc) =1 Then
  2187. li_Result = 1
  2188. END IF
  2189. IF li_Result=0 AND li_Row>0 Then
  2190. IF OF_GetChild(li_Row,ls_Name, dwo)=1 Then
  2191. Try
  2192. lds = Create n_dw2xls_DataStore
  2193. dwo2= dwo.Object //DataWindow.Syntax 和 DataWindow.Data同时使用dwo,会出错
  2194. lds.Create(dwo.Object.DataWindow.Syntax+"~r~n"+String(dwo2.Datawindow.Syntax.Data) )
  2195. lds.Modify("DataWindow.NoUserPrompt=yes")
  2196. ls_Processing =lds.Describe("DataWindow.Processing")
  2197. IF ls_Processing<>"!" AND ls_Processing<>"?" AND ls_Processing<>"" AND ls_Processing<>"2" AND Long(ls_Processing)<=5 Then
  2198. lds.OF_SetRetrieveData(False)
  2199. //为了让数据窗口的检索参数有值
  2200. IF OF_GetArguments(li_Row, lds.Describe("DataWindow.Table.Arguments"), OF_Describe(ls_Name+".Nest_Arguments"), la_Args, ls_ArgTypes )>0 Then
  2201. lds.OF_Retrieve(la_Args , ls_ArgTypes )
  2202. END IF
  2203. li_Result =2
  2204. END IF
  2205. Catch(RunTimeError er)
  2206. END TRY
  2207. END IF
  2208. END IF
  2209. IF li_Result =0 AND li_Row>0 Then
  2210. lds = Create n_dw2xls_DataStore
  2211. IF lds.OF_SetDataObject(OF_Describe(ls_Name+".DataObject")) Then
  2212. ls_Processing =lds.Describe("DataWindow.Processing")
  2213. IF ls_Processing<>"!" AND ls_Processing<>"?" AND ls_Processing<>"" AND ls_Processing<>"2" AND Long(ls_Processing)<=5 Then
  2214. lds.Modify("DataWindow.NoUserPrompt=yes")
  2215. lds.OF_SetRetrieveData(TRUE)
  2216. IF OF_GetArguments(li_Row, lds.Describe("DataWindow.Table.Arguments"), OF_Describe(ls_Name+".Nest_Arguments"), la_Args , ls_ArgTypes )>0 Then
  2217. lds.OF_Retrieve(la_Args , ls_ArgTypes )
  2218. END IF
  2219. li_Result =3
  2220. END IF
  2221. END IF
  2222. END IF
  2223. IF li_Result=0 Then
  2224. IF IsValid(anv_Object.inv_Report) Then
  2225. Destroy anv_Object.inv_Report
  2226. END IF
  2227. ELSE
  2228. IF Not IsValid(anv_Object.inv_Report) Then
  2229. anv_Object.Inv_Report = Create n_dw2xls_Requestor
  2230. END IF
  2231. lnv_Report =anv_Object.Inv_Report
  2232. lnv_Report.il_x = ai_x
  2233. lnv_Report.il_Y = ai_y
  2234. lnv_Report.il_x2 = ai_x2
  2235. lnv_Report.il_y2 = ai_y2
  2236. lnv_Report.ib_Child =TRUE
  2237. lnv_Report.OF_SetWinApi( OF_GetWinApi() )
  2238. END IF
  2239. IF li_Result=1 Then
  2240. IF lnv_Report.OF_SetRequestor(dwc, inv_Progress, inv_Layout )=1 Then
  2241. lnv_Report.il_RowCount =dwc.RowCount()
  2242. inv_ChildReports[UpperBound(inv_ChildReports)+1] = anv_Object
  2243. ELSE
  2244. li_Result = -1
  2245. END IF
  2246. ELSEIF li_Result>1 AND IsValid(lds) Then
  2247. lnv_Report.il_RowCount =lds.RowCount()
  2248. IF lnv_Report.il_RowCount = 0 Then //如果子数据窗口是个复合类型的数据窗口,则记录可能为0
  2249. IF lds.Describe("DataWindow.Processing")="5" THen
  2250. lds.InsertRow(0)
  2251. lnv_Report.il_RowCount =1
  2252. ELSEIF ls_Band="summary" OR ls_Band="footer" Then
  2253. lds.InsertRow(0)
  2254. lnv_Report.il_RowCount =1
  2255. END IF
  2256. END IF
  2257. lds.GroupCalc()
  2258. IF li_Result=2 Then
  2259. lnv_Report.idwo_Parent = dwo
  2260. END IF
  2261. IF lnv_Report.OF_SetRequestor(lds, inv_Progress, inv_Layout ) =1 Then
  2262. inv_NestReports[UpperBound(inv_NestReports)+1]=anv_Object
  2263. ELSE
  2264. li_Result =-1
  2265. END IF
  2266. END IF
  2267. IF li_Result>0 THEN
  2268. Return TRUE
  2269. ELSE
  2270. Return False
  2271. END IF
  2272. end function
  2273. public function integer of_getfirstcolumn ();Return ii_FirstColumn
  2274. end function
  2275. public function integer of_getlastcolumn ();Return ii_LastColumn
  2276. end function
  2277. public subroutine of_setfirstcolumn (readonly integer ai_column);ii_FirstColumn = ai_Column
  2278. end subroutine
  2279. public subroutine of_setlastcolumn (readonly integer ai_column);ii_LastColumn= ai_Column
  2280. end subroutine
  2281. public function integer of_getarguments (readonly long al_row, readonly string as_arguments, string as_nestarguments, ref any aa_argvalue[], ref string as_argtype[]);Int li , li_cnt,li_cnt2, li_Pos
  2282. String ls_Name, ls_Type, ls_Value,ls_Args[] ,ls_NestArgs[]
  2283. as_NestArguments = Trim(as_NestArguments)
  2284. IF Left(as_NestArguments,1)="(" Then
  2285. as_NestArguments = Mid(as_NestArguments,2, Len(as_NestArguments) -2)
  2286. END IF
  2287. IF as_Arguments<>"!" AND as_Arguments<>"" AND as_Arguments<>"?" Then
  2288. li_cnt = OF_ParseToArray(as_Arguments,"~n",ls_Args)
  2289. li_cnt2=OF_ParseToArray(as_NestArguments,",",ls_NestArgs)
  2290. IF li_cnt<> li_cnt2 Then
  2291. Return 0
  2292. END IF
  2293. For li=1 To li_cnt
  2294. li_Pos=Pos(ls_Args[li],"~t")
  2295. ls_Name=Left(ls_Args[li],li_Pos -1)
  2296. ls_Type=Mid(ls_Args[li],li_Pos+1)
  2297. ls_NestArgs[li] = Trim(ls_NestArgs[li])
  2298. IF Left(ls_NestArgs[li],1)="(" Then
  2299. ls_NestArgs[li] = Mid(ls_NestArgs[li],2, Len(ls_NestArgs[li]) -2)
  2300. END IF
  2301. IF Left(ls_NestArgs[li],1)='"' Then
  2302. ls_NestArgs[li] = Mid(ls_NestArgs[li],2, Len(ls_NestArgs[li]) -2)
  2303. END IF
  2304. ls_Value=OF_Describe('evaluate("'+ls_NestArgs[li] +'",'+String(al_Row)+' )' )
  2305. IF ls_Value="?" OR ls_Value="!" Then
  2306. ls_Value=""
  2307. END IF
  2308. Choose Case ls_Type
  2309. Case "string"
  2310. aa_ArgValue[li]=ls_Value
  2311. Case "number"
  2312. aa_ArgValue[li]=Double(ls_Value)
  2313. Case "decimal"
  2314. aa_ArgValue[li]=Dec(ls_Value)
  2315. Case "datetime"
  2316. aa_ArgValue[li]=DateTime(blob(ls_Value))
  2317. Case "date"
  2318. aa_ArgValue[li]=Date(ls_Value)
  2319. Case "time"
  2320. aa_ArgValue[li]=Time(ls_Value)
  2321. END CHOOSE
  2322. as_argType[li] = ls_Type
  2323. Next
  2324. END IF
  2325. Return li_cnt
  2326. end function
  2327. public function long of_output (readonly unsignedlong al_hsheet, readonly long al_beginrow);Int li,lj ,li_Increase,li_Height
  2328. Long li_Row, li_CurRow ,li_RowCount ,li_Header_Rows
  2329. Boolean lb_HasDetail, lb_TrailerFlag
  2330. n_dw2xls_Band lnv_Band ,lnv_Detail
  2331. //Nest类型的数据窗口,如果子数据窗口没有数据,在数据窗口上面是不显示内容的
  2332. IF inv_Layout.OF_IsNested() AND ib_Child AND il_RowCount=0 Then
  2333. Return al_beginrow
  2334. END IF
  2335. //初始化列宽,行高
  2336. IF Not ib_Child Then
  2337. inv_Layout.OF_Write_ColumnInfo(inv_Api, al_hSheet)
  2338. END IF
  2339. li_CurRow = al_beginrow
  2340. li_RowCount = OF_RowCount()
  2341. IF ( inv_Layout.OF_IsNested()=False OR inv_Layout.OF_RowCount()=1) OR ib_Child=False Then
  2342. li_Increase =1
  2343. ELSE
  2344. li_Increase =0
  2345. END IF
  2346. For li=1 To UpperBound(inv_Bands)
  2347. inv_Bands[li].OF_SortObject_Row()
  2348. inv_Bands[li].OF_SetWorkSheet(al_hSheet)
  2349. NEXT
  2350. IF is_Processing="4" Then
  2351. For li=1 To ii_HeaderCount
  2352. IF of_containtband("header["+String(li)+"]" ) Then
  2353. lnv_Band = OF_GetBand("header["+String(li)+"]" )
  2354. IF li_RowCount>0 Then
  2355. li_CurRow +=lnv_Band.OF_OutPut( 1, li_CurRow)
  2356. ELSE
  2357. li_CurRow +=lnv_Band.OF_OutPut(0 , li_CurRow)
  2358. END IF
  2359. END IF
  2360. inv_Progress.OF_Progress(li_Increase )
  2361. Next
  2362. ELSE
  2363. IF of_containtband("header") Then
  2364. lnv_Band = OF_GetBand("header")
  2365. IF li_RowCount>0 Then
  2366. li_CurRow +=lnv_Band.OF_OutPut( 1, li_CurRow)
  2367. ELSE
  2368. li_CurRow +=lnv_Band.OF_OutPut(0 , li_CurRow)
  2369. END IF
  2370. inv_Progress.OF_Progress(li_Increase )
  2371. END IF
  2372. END IF
  2373. li_Header_Rows = li_CurRow
  2374. IF inv_Progress.ib_Cancel Then
  2375. Return -1
  2376. END IF
  2377. IF of_containtband("detail") Then
  2378. lnv_Detail= OF_GetBand("detail")
  2379. lb_HasDetail =TRUE
  2380. IF lnv_Detail.OF_RowCount()=1 AND ib_Child=False AND ib_Nested=False AND is_Processing<>'5' Then
  2381. inv_Api.SetDefRowHeight(al_hSheet, lnv_Detail.OF_GetRowHeight(1) )
  2382. END IF
  2383. ELSE
  2384. lb_HasDetail =FALSE
  2385. IF ii_GroupLevels=1 AND of_containtband("trailer.1") Then
  2386. lnv_Band = OF_GetBand("trailer.1")
  2387. IF lnv_Band.OF_RowCount()=1 AND ib_Child=False AND ib_Nested=False AND is_Processing<>'5' Then
  2388. li_Height= lnv_Band.OF_GetRowHeight(1)
  2389. inv_Api.SetDefRowHeight( al_hSheet,li_Height)
  2390. END IF
  2391. END IF
  2392. END IF
  2393. //如果细节区没有对象,而且没有分组,则避免循环
  2394. IF lb_HasDetail=False AND ii_GroupLevels<=0 Then
  2395. li_RowCount =0
  2396. END IF
  2397. For li_Row=1 TO li_RowCount
  2398. lb_TrailerFlag=False
  2399. FOR li=1 To ii_GroupLevels
  2400. IF inv_Progress.ib_Cancel Then
  2401. Return -1
  2402. END IF
  2403. IF OF_FindGroupChange(li_Row,li)=li_Row Then //分组的开始
  2404. IF li_Row<>1 AND Not lb_TrailerFlag Then //第一次,不用输出组的尾区
  2405. lb_TrailerFlag=True
  2406. For lj=ii_GroupLevels TO li Step -1 //组尾区的显示顺序,与组头区是倒过来的
  2407. IF of_containtband("trailer."+String(lj)) Then
  2408. lnv_Band = OF_GetBand("trailer."+String(lj ) )
  2409. li_CurRow +=lnv_Band.OF_OutPut( li_Row -1 , li_CurRow)
  2410. ib_Detail_Begin =TRUE
  2411. END IF
  2412. //是否按组分页打印
  2413. IF lj<=UpperBound(ib_GroupNewPage) Then
  2414. IF ib_GroupNewPage[lj] Then
  2415. inv_Layout.OF_AddHPageBreak(li_CurRow) //保存分页的行号
  2416. END IF
  2417. END IF
  2418. Next
  2419. END IF
  2420. IF of_containtband("header."+String(li)) Then
  2421. lnv_Band = OF_GetBand("header."+String(li) )
  2422. li_CurRow +=lnv_Band.OF_OutPut( li_Row , li_CurRow)
  2423. ib_Detail_Begin =TRUE
  2424. END IF
  2425. END IF
  2426. Next
  2427. IF inv_Progress.ib_Cancel Then
  2428. Return -1
  2429. END IF
  2430. IF lb_HasDetail Then
  2431. li_CurRow += lnv_Detail.OF_OutPut( li_Row , li_CurRow)
  2432. IF ib_Nested Then
  2433. li_Height =lnv_Detail.OF_GetBottomSpaceHeight()
  2434. IF li_Height>0 Then
  2435. li_Height = ( UnitsToPixels(li_Height,YUnitsToPixels!)+2) *1440 /inv_Layout.ii_LOGPIXELSY
  2436. li_CurRow++
  2437. inv_Api.SetRowHeight(al_hSheet, li_CurRow, li_Height)
  2438. END IF
  2439. END IF
  2440. END IF
  2441. inv_Progress.OF_Progress(li_Increase )
  2442. li_Row=li_Row+ii_Rows_Per_Detail -1
  2443. ib_Detail_Begin =False
  2444. Next
  2445. IF inv_Progress.ib_Cancel Then
  2446. Return -1
  2447. END IF
  2448. //输出所有组的最后一组脚尾区
  2449. IF li_RowCount>0 Then
  2450. FOR li=ii_GroupLevels To 1 Step -1
  2451. IF of_containtband("trailer."+String(li) ) Then
  2452. lnv_Band = OF_GetBand("trailer."+String(li) )
  2453. li_CurRow +=lnv_Band.OF_OutPut( li_RowCount , li_CurRow)
  2454. END IF
  2455. NEXT
  2456. END IF
  2457. IF inv_Progress.ib_Cancel Then
  2458. Return -1
  2459. END IF
  2460. li_RowCount = OF_RowCount()
  2461. IF li_RowCount>0 Then
  2462. IF of_containtband("summary") Then
  2463. lnv_Band = OF_GetBand("summary")
  2464. li_CurRow +=lnv_Band.OF_OutPut( li_RowCount , li_CurRow)
  2465. inv_Progress.OF_Progress(li_Increase)
  2466. END IF
  2467. END IF
  2468. IF inv_Progress.ib_Cancel Then
  2469. Return -1
  2470. END IF
  2471. IF of_containtband("footer") Then
  2472. lnv_Band = OF_GetBand("footer")
  2473. li_CurRow +=lnv_Band.OF_OutPut( li_RowCount , li_CurRow)
  2474. inv_Progress.OF_Progress(li_Increase)
  2475. END IF
  2476. //输出打印设置
  2477. IF Not ib_Child Then
  2478. inv_Layout.OF_Write_PageBreak(inv_Api, al_hSheet )
  2479. OF_Write_PrintSetting(al_hSheet )
  2480. IF li_Header_Rows>0 AND is_Processing<>'3' AND is_Processing<>'5' Then
  2481. inv_Api.SetRepeatRows(al_hSheet, 0, li_Header_Rows)
  2482. IF inv_Progress.ib_FreezeTitles Then
  2483. inv_Api.SetFreeze(al_hSheet, li_Header_Rows ,0 )
  2484. inv_Layout.ii_Freeze_Rows =li_Header_Rows
  2485. END IF
  2486. END IF
  2487. END IF
  2488. Return li_CurRow // -al_beginrow
  2489. end function
  2490. public function integer of_getobject_x1 (readonly string as_name);Int li_X
  2491. String ls_Value ,ls_Exp
  2492. OF_GetProperty(as_Name,"x", ls_Value, ls_Exp)
  2493. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2494. ls_Exp = OF_Evaluate(1, ls_Exp)
  2495. END IF
  2496. IF IsNumber(ls_Exp) Then
  2497. li_X = Long(ls_Exp)
  2498. ELSE
  2499. li_X = Long(ls_Value)
  2500. END IF
  2501. IF li_X<0 Then
  2502. li_X =0
  2503. END IF
  2504. IF is_Units='1' Then
  2505. li_X = PixelsToUnits(li_X, XPixelsToUnits!)
  2506. ELSEIF is_Units='2' Then
  2507. li_X = PixelsToUnits(inv_Api.OF_InchToPixels(li_X/1000 ) , XPixelsToUnits!)
  2508. ELSEIF is_Units='3' Then
  2509. li_X = PixelsToUnits(inv_Api.OF_CMToPixels(li_X /1000), XPixelsToUnits!)
  2510. END IF
  2511. IF is_Units<>'0' Then
  2512. IF li_X<0 Then
  2513. li_X+=65536
  2514. END IF
  2515. END IF
  2516. Return li_X
  2517. end function
  2518. public function integer of_getobject_x2 (readonly string as_name);Int li_X ,li_Width
  2519. String ls_Value ,ls_Exp
  2520. OF_GetProperty(as_Name,"x", ls_Value, ls_Exp)
  2521. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2522. ls_Exp = OF_Evaluate(1, ls_Exp)
  2523. END IF
  2524. IF IsNumber(ls_Exp) Then
  2525. li_X = Long(ls_Exp)
  2526. ELSE
  2527. li_X = Long(ls_Value)
  2528. END IF
  2529. OF_GetProperty(as_Name,"Width", ls_Value, ls_Exp)
  2530. IF ls_Exp<>'' AND IsNumber(ls_Exp)=False Then
  2531. ls_Exp = OF_Evaluate(1, ls_Exp)
  2532. END IF
  2533. IF IsNumber(ls_Exp) Then
  2534. li_Width = Long(ls_Exp)
  2535. ELSE
  2536. li_Width = Long(ls_Value)
  2537. END IF
  2538. IF li_X<0 Then
  2539. li_X=0
  2540. END IF
  2541. IF li_Width<0 Then
  2542. li_Width=0
  2543. END IF
  2544. IF is_Units='1' Then
  2545. li_X = PixelsToUnits(li_X, XPixelsToUnits!)
  2546. li_Width = PixelsToUnits(li_Width, XPixelsToUnits!)
  2547. ELSEIF is_Units='2' Then
  2548. li_X = PixelsToUnits(inv_Api.OF_InchToPixels(li_X/1000 ) , XPixelsToUnits!)
  2549. li_Width = PixelsToUnits(inv_Api.OF_InchToPixels(li_Width/1000 ) , XPixelsToUnits!)
  2550. ELSEIF is_Units='3' Then
  2551. li_X = PixelsToUnits(inv_Api.OF_CMToPixels(li_X /1000), XPixelsToUnits!)
  2552. li_Width = PixelsToUnits(inv_Api.OF_CMToPixels(li_Width /1000), XPixelsToUnits!)
  2553. END IF
  2554. IF is_Units<>'0' Then
  2555. IF li_X<0 Then
  2556. li_X+=65536
  2557. END IF
  2558. IF li_Width<0 Then
  2559. li_Width+=65536
  2560. END IF
  2561. END IF
  2562. Return li_X + li_Width
  2563. end function
  2564. on n_dw2xls_requestor.create
  2565. call super::create
  2566. TriggerEvent( this, "constructor" )
  2567. end on
  2568. on n_dw2xls_requestor.destroy
  2569. TriggerEvent( this, "destructor" )
  2570. call super::destroy
  2571. end on
  2572. event destructor;Int li
  2573. IF IsValid(inv_Layout) Then
  2574. Destroy inv_Layout
  2575. END IF
  2576. For li=1 To UpperBound( inv_Bands)
  2577. Destroy inv_Bands[li]
  2578. Next
  2579. For li=1 To UpperBound( inv_Exps)
  2580. Destroy inv_Exps[li]
  2581. Next
  2582. Try
  2583. IF IsValid(ids_Composite) Then
  2584. ids_Composite.Reset()
  2585. Destroy ids_Composite
  2586. END IF
  2587. Catch(RunTimeError er)
  2588. End TRY
  2589. IF IsValid(ids_Requestor) AND ib_Child Then
  2590. Destroy ids_Requestor
  2591. END IF
  2592. end event