n_xls_worksheet.sru 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458
  1. $PBExportHeader$n_xls_worksheet.sru
  2. forward
  3. global type n_xls_worksheet from nonvisualobject
  4. end type
  5. end forward
  6. global type n_xls_worksheet from nonvisualobject
  7. end type
  8. global n_xls_worksheet n_xls_worksheet
  9. type variables
  10. PUBLIC STRING is_worksheetname
  11. PUBLIC n_xls_subroutines invo_sub
  12. PUBLIC UINT ii_index
  13. PUBLIC BOOLEAN ib_selected
  14. PUBLIC ULONG il_offset
  15. PUBLIC ULONG il_datasize
  16. PROTECTED BLOB ib_data
  17. PUBLIC UINT ii_print_rowmin
  18. PUBLIC UINT ii_print_rowmax
  19. PUBLIC INTEGER ii_print_colmin
  20. PUBLIC UINT ii_title_rowmin
  21. PUBLIC UINT ii_title_rowmax
  22. PUBLIC INTEGER ii_title_colmin
  23. PUBLIC INTEGER ii_title_colmax
  24. PUBLIC INTEGER ii_print_colmax
  25. PUBLIC BLOB ib_worksheetname
  26. PROTECTED ULONG il_xls_rowmax = 65536
  27. PROTECTED ULONG il_xls_colmax = 256
  28. PROTECTED ULONG il_xls_strmax = 255
  29. PROTECTED ULONG il_dim_rowmin
  30. PROTECTED ULONG il_dim_colmin
  31. PROTECTED ULONG il_dim_rowmax
  32. PROTECTED ULONG il_dim_colmax
  33. PROTECTED BOOLEAN ib_dim_changed
  34. PROTECTED INTEGER ii_active_pane = 3
  35. PROTECTED BOOLEAN ib_frozen
  36. PROTECTED UINT ii_paper_size
  37. PROTECTED INTEGER ii_orientation = 1
  38. PROTECTED BLOB ib_header
  39. PROTECTED BLOB ib_footer
  40. PROTECTED UINT ii_vcenter
  41. PROTECTED UINT ii_hcenter
  42. PROTECTED DOUBLE id_margin_head = 0.5
  43. PROTECTED DOUBLE id_margin_foot = 0.5
  44. PROTECTED DOUBLE id_margin_left = 0.75
  45. PROTECTED DOUBLE id_margin_right = 0.75
  46. PROTECTED DOUBLE id_margin_top = 1
  47. PROTECTED DOUBLE id_margin_bottom = 1
  48. PROTECTED BOOLEAN ib_print_gridlines = False
  49. PROTECTED BOOLEAN ib_screen_gridlines = False
  50. PROTECTED BOOLEAN ib_print_headers
  51. PROTECTED BOOLEAN ib_Print_NoColor =True //是否单色打印 2004 -11 - 11
  52. PROTECTED BOOLEAN ib_fit_page
  53. PROTECTED UINT ii_fit_width
  54. PROTECTED UINT ii_fit_height
  55. PROTECTED UINT ii_hbreaks[]
  56. PROTECTED UINT ii_vbreaks[]
  57. PROTECTED BOOLEAN ib_protect
  58. PROTECTED STRING is_password
  59. PROTECTED DOUBLE id_col_sizes[]
  60. PROTECTED DOUBLE id_row_sizes[]
  61. PROTECTED Double id_Default_Row_Height = 18
  62. PROTECTED INTEGER ii_zoom = 100
  63. PROTECTED INTEGER ii_print_scale = 100
  64. PROTECTED BOOLEAN ib_leading_zeros
  65. PROTECTED UINT ii_limit = 8224
  66. PROTECTED BOOLEAN ib_col_hiddens[]
  67. PROTECTED BOOLEAN ib_row_hiddens[]
  68. PUBLIC n_xls_format invo_url_format
  69. PUBLIC n_xls_workbook invo_workbook
  70. PUBLIC n_xls_colinfo invo_colinfo[]
  71. PUBLIC n_xls_selection invo_selection
  72. PUBLIC n_xls_panes invo_panes
  73. PUBLIC n_associated_ulong_srv invo_key_col_sizes
  74. PUBLIC n_associated_ulong_srv invo_key_row_sizes
  75. PUBLIC n_associated_ulong_srv invo_key_col_formats
  76. PUBLIC n_associated_ulong_srv invo_key_row_formats
  77. PROTECTED n_xls_format invo_col_formats[]
  78. PROTECTED n_xls_format invo_row_formats[]
  79. PROTECTED n_associated_ulong_srv invo_key_col_hiddens
  80. PROTECTED n_associated_ulong_srv invo_key_row_hiddens
  81. PROTECTED n_xls_data invo_data
  82. PROTECTED n_xls_data invo_header
  83. protected:
  84. n_xls_Row inv_Rows[]
  85. Datastore ids_Mergecells
  86. end variables
  87. forward prototypes
  88. public function integer of_set_row_height (long al_row, long al_height)
  89. public function integer of_set_row_format (long al_row, n_xls_format anvo_format)
  90. public function integer of_set_row_hidden (long al_row, boolean ab_hidden)
  91. public function integer of_set_column_width (long al_col, long al_width)
  92. public function integer of_set_column_format (long al_col, n_xls_format anvo_format)
  93. public function integer of_set_column_hidden (long al_col, boolean ab_hidden)
  94. public function string of_get_name ()
  95. public function blob of_get_name_unicode ()
  96. public function integer of_select ()
  97. public function integer of_activate ()
  98. public function integer of_set_first_sheet ()
  99. public function integer of_protect (string as_password)
  100. public function integer of_set_column (unsignedinteger ai_firstcol, unsignedinteger ai_lastcol, double ad_width, n_xls_format anvo_format, boolean ab_hidden)
  101. public function integer of_set_selection (unsignedinteger ai_first_row, unsignedinteger ai_first_col, unsignedinteger ai_last_row, unsignedinteger ai_last_col)
  102. public function integer of_set_selection (unsignedinteger ai_row, unsignedinteger ai_col)
  103. public function integer of_thaw_panes (double ad_y, double ad_x, unsignedinteger ai_rowtop, unsignedinteger ai_colleft)
  104. public function integer of_freeze_panes (unsignedinteger ai_row, unsignedinteger ai_col, unsignedinteger ai_rowtop, unsignedinteger ai_colleft)
  105. public function integer of_set_landscape ()
  106. public function integer of_set_paper (unsignedinteger ai_paper_size)
  107. public function integer of_set_paper ()
  108. public function integer of_set_header (string as_header, double ad_margin_head)
  109. public function integer of_set_footer (string as_footer, double ad_margin_foot)
  110. public function integer of_set_header (blob ab_header, double ad_margin_head)
  111. public function integer of_set_footer (blob ab_footer, double ad_margin_foot)
  112. public function integer of_center_horizontally ()
  113. public function integer of_center_horizontally (boolean ab_option)
  114. public function integer of_center_vertically ()
  115. public function integer of_center_vertically (boolean ab_option)
  116. public function integer of_set_margins (double ad_margin)
  117. public function integer of_set_margins_lr (double ad_margin)
  118. public function integer of_set_margins_tb (double ad_margin)
  119. public function integer of_set_margin_left (double ad_margin)
  120. public function integer of_set_margin_right (double ad_margin)
  121. public function integer of_set_margin_top (double ad_margin)
  122. public function integer of_set_margin_bottom (double ad_margin)
  123. public function integer of_repeat_rows (unsignedinteger ai_first_row, unsignedinteger ai_last_row)
  124. public function integer of_repeat_columns (unsignedinteger ai_first_col, unsignedinteger ai_last_col)
  125. public function integer of_print_area (unsignedinteger ai_first_row, unsignedinteger ai_first_col, unsignedinteger ai_last_row, unsignedinteger ai_last_col)
  126. public function integer of_hide_gridlines (unsignedinteger ai_option)
  127. public function integer of_print_row_col_headers (boolean ab_print_headers)
  128. public function integer of_fit_to_pages (unsignedinteger ai_width, unsignedinteger ai_height)
  129. public function integer of_add_h_pagebreak (unsignedinteger ai_hbreak)
  130. public function integer of_add_v_pagebreak (unsignedinteger ai_vbreak)
  131. public function integer of_set_zoom (unsignedinteger ai_scale)
  132. public function integer of_set_print_scale (unsignedinteger ai_scale)
  133. public function integer of_set_row_height (long al_row, double ad_height)
  134. public function integer of_set_column_width (long al_col, double ad_width)
  135. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename, readonly unsignedinteger ai_x, readonly unsignedinteger ai_y, readonly double ad_scale_width, readonly double ad_scale_height)
  136. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename)
  137. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename, readonly unsignedinteger ai_x, readonly unsignedinteger ai_y)
  138. public function blob of_add_continue (blob ab_data)
  139. public function integer of_append_data (blob ab_data)
  140. public function integer of_append_header (blob ab_data)
  141. public function integer of_close ()
  142. public function unsignedlong of_encode_password (string as_password)
  143. public function blob of_get_data ()
  144. public function unsignedinteger of_get_excel_height (double ad_value)
  145. public function unsignedinteger of_get_excel_width (double ad_value)
  146. public function integer of_position_image (unsignedinteger ai_col_start, unsignedinteger ai_row_start, unsignedinteger ai_x1, unsignedinteger ai_y1, unsignedinteger ai_width, unsignedinteger ai_height)
  147. public function integer of_process_bitmap (readonly string as_bitmap_filename, ref long al_width, ref long al_height, ref long al_size, ref blob ab_data)
  148. public function integer of_set_row (unsignedinteger ai_row, double ad_height, n_xls_format anvo_format, boolean ab_hidden)
  149. public function integer of_write_data (olestream astr_book)
  150. public function integer of_sort_pagebreaks (ref unsignedinteger ai_page_breaks[])
  151. public function integer of_store_bof (unsignedinteger ai_type)
  152. public function integer of_store_colinfo (n_xls_colinfo anvo_colinfo)
  153. public function integer of_store_defcol ()
  154. public function integer of_store_dimensions ()
  155. public function integer of_store_eof ()
  156. public function integer of_store_externcount (unsignedinteger ai_count)
  157. public function integer of_store_externsheet (string as_sheetname)
  158. public function integer of_store_footer ()
  159. public function integer of_store_gridset ()
  160. public function integer of_store_hbreak ()
  161. public function integer of_store_hcenter ()
  162. protected function integer of_store_header ()
  163. protected function integer of_store_margin_bottom ()
  164. protected function integer of_store_margin_left ()
  165. public function integer of_store_margin_right ()
  166. protected function integer of_store_margin_top ()
  167. public function integer of_store_obj_picture (unsignedinteger ai_col_start, unsignedinteger ai_x1, unsignedinteger ai_row_start, unsignedinteger ai_y1, unsignedinteger ai_col_end, unsignedinteger ai_x2, unsignedinteger ai_row_end, unsignedinteger ai_y2)
  168. public function integer of_store_panes (n_xls_panes anvo_panes)
  169. public function integer of_store_password ()
  170. public function integer of_store_print_gridlines ()
  171. public function integer of_store_print_headers ()
  172. protected function integer of_store_protect ()
  173. public function integer of_store_selection (n_xls_selection anvo_selection)
  174. public function integer of_store_setup ()
  175. public function integer of_store_vbreak ()
  176. public function integer of_store_vcenter ()
  177. public function integer of_store_window2 ()
  178. public function integer of_store_wsbool ()
  179. public function integer of_store_zoom ()
  180. public function integer of_store_cells ()
  181. public function n_xls_cell of_getcell (unsignedinteger row, unsignedinteger col)
  182. public subroutine of_reg_cellformat (n_xls_cell anvo_firstcell)
  183. public subroutine of_mergecells (readonly unsignedinteger row1, readonly unsignedinteger col1, readonly unsignedinteger row2, readonly unsignedinteger col2)
  184. public subroutine of_setcellempty (unsignedinteger ai_row, unsignedinteger ai_col)
  185. public function boolean of_isvalidcell (unsignedinteger ai_row, unsignedinteger ai_col, ref n_xls_cell anv_cell)
  186. public function integer of_store_default_row_height ()
  187. public function integer of_set_orientation (integer ai_orientation)
  188. protected function integer of_store_mergecells ()
  189. public subroutine of_priorcell_wraptext (unsignedinteger ai_row, unsignedinteger ai_col)
  190. public function integer of_store_guts ()
  191. public subroutine of_set_default_rowheight (double ad_height)
  192. public subroutine of_set_print_nocolor (boolean ab_flag)
  193. public subroutine of_set_cellborder ()
  194. end prototypes
  195. public function integer of_set_row_height (long al_row, long al_height);integer li_ret = 1
  196. n_xls_format lnvo_format
  197. boolean lb_hidden
  198. setnull(lnvo_format)
  199. setnull(lb_hidden)
  200. li_ret = of_set_row(al_row, al_height, lnvo_format, lb_hidden)
  201. return li_ret
  202. end function
  203. public function integer of_set_row_format (long al_row, n_xls_format anvo_format);
  204. integer li_ret = 1
  205. uint li_height
  206. boolean lb_hidden
  207. setnull(li_height)
  208. setnull(lb_hidden)
  209. li_ret = of_set_row(al_row, li_height, anvo_format, lb_hidden)
  210. return li_ret
  211. end function
  212. public function integer of_set_row_hidden (long al_row, boolean ab_hidden);integer li_ret = 1
  213. n_xls_format lnvo_format
  214. uint li_height
  215. setnull(li_height)
  216. setnull(lnvo_format)
  217. li_ret = of_set_row(al_row, li_height, lnvo_format, ab_hidden)
  218. return li_ret
  219. end function
  220. public function integer of_set_column_width (long al_col, long al_width);integer li_ret = 1
  221. n_xls_format lnvo_format
  222. boolean lb_hidden
  223. ulong ll_i
  224. ll_i = invo_key_col_formats.of_get_key_index(al_col)
  225. if ll_i > 0 then
  226. lnvo_format = invo_col_formats[ll_i]
  227. else
  228. setnull(lnvo_format)
  229. end if
  230. ll_i = invo_key_col_hiddens.of_get_key_index(al_col)
  231. if ll_i > 0 then
  232. lb_hidden = ib_col_hiddens[ll_i]
  233. else
  234. setnull(lb_hidden)
  235. end if
  236. li_ret = of_set_column(al_col, al_col, al_width, lnvo_format, lb_hidden)
  237. return li_ret
  238. end function
  239. public function integer of_set_column_format (long al_col, n_xls_format anvo_format);integer li_ret = 1
  240. uint li_width
  241. boolean lb_hidden
  242. ulong ll_i
  243. ll_i = invo_key_col_sizes.of_get_key_index(al_col)
  244. if ll_i > 0 then
  245. li_width = id_col_sizes[ll_i]
  246. else
  247. setnull(li_width)
  248. end if
  249. ll_i = invo_key_col_hiddens.of_get_key_index(al_col)
  250. if ll_i > 0 then
  251. lb_hidden = ib_col_hiddens[ll_i]
  252. else
  253. setnull(lb_hidden)
  254. end if
  255. li_ret = of_set_column(al_col, al_col, li_width, anvo_format, lb_hidden)
  256. return li_ret
  257. end function
  258. public function integer of_set_column_hidden (long al_col, boolean ab_hidden);integer li_ret = 1
  259. n_xls_format lnvo_format
  260. uint li_width
  261. ulong ll_i
  262. ll_i = invo_key_col_formats.of_get_key_index(al_col)
  263. if ll_i > 0 then
  264. lnvo_format = invo_col_formats[ll_i]
  265. else
  266. setnull(lnvo_format)
  267. end if
  268. ll_i = invo_key_col_sizes.of_get_key_index(al_col)
  269. if ll_i > 0 then
  270. li_width = id_col_sizes[ll_i]
  271. else
  272. setnull(li_width)
  273. end if
  274. li_ret = of_set_column(al_col, al_col, li_width, lnvo_format, ab_hidden)
  275. return li_ret
  276. end function
  277. public function string of_get_name ();return is_worksheetname
  278. end function
  279. public function blob of_get_name_unicode ();return ib_worksheetname
  280. end function
  281. public function integer of_select ();integer li_ret=1
  282. ib_selected=true
  283. return li_ret
  284. end function
  285. public function integer of_activate ();integer li_ret
  286. li_ret = of_select()
  287. if li_ret = 1 then
  288. invo_workbook.ii_activesheet = ii_index
  289. end if
  290. return li_ret
  291. end function
  292. public function integer of_set_first_sheet ();integer li_ret = 1
  293. invo_workbook.ii_firstsheet = ii_index
  294. return li_ret
  295. end function
  296. public function integer of_protect (string as_password);integer li_ret = 1
  297. ib_protect = true
  298. is_password = as_password
  299. return li_ret
  300. end function
  301. public function integer of_set_column (unsignedinteger ai_firstcol, unsignedinteger ai_lastcol, double ad_width, n_xls_format anvo_format, boolean ab_hidden);integer li_ret = 1
  302. double ld_width
  303. uint li_i
  304. ulong ll_key
  305. n_xls_format lnvo_format
  306. n_xls_colinfo lnvo_colinfo
  307. lnvo_colinfo = create n_xls_colinfo
  308. lnvo_colinfo.ii_firstcol = ai_firstcol
  309. lnvo_colinfo.ii_lastcol = ai_lastcol
  310. lnvo_colinfo.id_width = ad_width
  311. if not isnull(anvo_format) then
  312. if isvalid(anvo_format) then
  313. lnvo_format = create n_xls_format
  314. lnvo_format.of_copy(anvo_format)
  315. invo_workbook.of_reg_format(lnvo_format)
  316. else
  317. setnull(lnvo_format)
  318. end if
  319. else
  320. setnull(lnvo_format)
  321. end if
  322. lnvo_colinfo.invo_format = lnvo_format
  323. lnvo_colinfo.ib_hidden = ab_hidden
  324. invo_colinfo[upperbound(invo_colinfo) + 1] = lnvo_colinfo
  325. if ab_hidden then
  326. ld_width = 0
  327. else
  328. ld_width = ad_width
  329. end if
  330. for li_i = ai_firstcol to ai_lastcol
  331. ll_key = invo_key_col_sizes.of_find_key(li_i)
  332. if ll_key < 1 then
  333. ll_key = invo_key_col_sizes.of_add_key(li_i)
  334. end if
  335. id_col_sizes[ll_key] = ad_width
  336. next
  337. if not isnull(ab_hidden) then
  338. for li_i = ai_firstcol to ai_lastcol
  339. ll_key = invo_key_col_hiddens.of_find_key(li_i)
  340. if ll_key < 1 then
  341. ll_key = invo_key_col_hiddens.of_add_key(li_i)
  342. end if
  343. ib_col_hiddens[ll_key] = ab_hidden
  344. next
  345. end if
  346. if not isnull(anvo_format) then
  347. if isvalid(anvo_format) then
  348. for li_i = ai_firstcol to ai_lastcol
  349. ll_key = invo_key_col_formats.of_find_key(li_i)
  350. if ll_key < 1 then
  351. ll_key = invo_key_col_formats.of_add_key(li_i)
  352. end if
  353. invo_col_formats[ll_key] = anvo_format
  354. next
  355. end if
  356. end if
  357. return li_ret
  358. end function
  359. public function integer of_set_selection (unsignedinteger ai_first_row, unsignedinteger ai_first_col, unsignedinteger ai_last_row, unsignedinteger ai_last_col);integer li_ret = 1
  360. invo_selection.ii_first_row = ai_first_row
  361. invo_selection.ii_last_row = ai_last_row
  362. invo_selection.ii_first_col = ai_first_col
  363. invo_selection.ii_last_col = ai_last_col
  364. return li_ret
  365. end function
  366. public function integer of_set_selection (unsignedinteger ai_row, unsignedinteger ai_col);integer li_ret = 1
  367. invo_selection.ii_first_row = ai_row
  368. invo_selection.ii_last_row = ai_row
  369. invo_selection.ii_first_col = ai_col
  370. invo_selection.ii_last_col = ai_col
  371. return li_ret
  372. end function
  373. public function integer of_thaw_panes (double ad_y, double ad_x, unsignedinteger ai_rowtop, unsignedinteger ai_colleft);integer li_ret = 1
  374. if isnull(invo_panes) then
  375. invo_panes = create n_xls_panes
  376. end if
  377. invo_panes.id_y = ad_y
  378. invo_panes.id_x = ad_x
  379. invo_panes.ii_rowtop = ai_rowtop
  380. invo_panes.ii_colleft = ai_colleft
  381. ib_frozen = false
  382. return li_ret
  383. end function
  384. public function integer of_freeze_panes (unsignedinteger ai_row, unsignedinteger ai_col, unsignedinteger ai_rowtop, unsignedinteger ai_colleft);integer li_ret = 1
  385. if isnull(invo_panes) then
  386. invo_panes = create n_xls_panes
  387. end if
  388. invo_panes.id_y = ai_row
  389. invo_panes.id_x = ai_col
  390. invo_panes.ii_rowtop = ai_rowtop
  391. invo_panes.ii_colleft = ai_colleft
  392. ib_frozen = true
  393. return li_ret
  394. end function
  395. public function integer of_set_landscape ();integer li_ret =1
  396. ii_orientation=0
  397. return li_ret
  398. end function
  399. public function integer of_set_paper (unsignedinteger ai_paper_size);integer li_ret=1
  400. ii_paper_size = ai_paper_size
  401. return li_ret
  402. end function
  403. public function integer of_set_paper ();return of_set_paper(0)
  404. end function
  405. public function integer of_set_header (string as_header, double ad_margin_head);return of_set_header(invo_sub.to_unicode(as_header), ad_margin_head)
  406. end function
  407. public function integer of_set_footer (string as_footer, double ad_margin_foot);return of_set_footer(invo_sub.to_unicode(as_footer), ad_margin_foot)
  408. end function
  409. public function integer of_set_header (blob ab_header, double ad_margin_head);integer li_ret = 1
  410. if len(ab_header) / 2 >= 255 then
  411. messagebox("Error", "Header string must be less than 255 characters", stopsign!)
  412. li_ret = -1
  413. end if
  414. if li_ret = 1 then
  415. ib_header = ab_header
  416. if isnull(ad_margin_head) then
  417. id_margin_head = 0.50
  418. else
  419. id_margin_head = ad_margin_head
  420. end if
  421. end if
  422. return li_ret
  423. end function
  424. public function integer of_set_footer (blob ab_footer, double ad_margin_foot);integer li_ret = 1
  425. if len(ab_footer) / 2 >= 255 then
  426. messagebox("Error", "Footer string must be less than 255 characters", stopsign!)
  427. li_ret = -1
  428. end if
  429. if li_ret = 1 then
  430. ib_footer = ab_footer
  431. if isnull(ad_margin_foot) then
  432. id_margin_foot = 0.50
  433. else
  434. id_margin_foot = ad_margin_foot
  435. end if
  436. end if
  437. return li_ret
  438. end function
  439. public function integer of_center_horizontally ();return of_center_horizontally(true)
  440. end function
  441. public function integer of_center_horizontally (boolean ab_option);integer li_ret = 1
  442. if ab_option then
  443. ii_hcenter = 1
  444. else
  445. ii_hcenter = 0
  446. end if
  447. return li_ret
  448. end function
  449. public function integer of_center_vertically ();return of_center_vertically(true)
  450. end function
  451. public function integer of_center_vertically (boolean ab_option);integer li_ret = 1
  452. if ab_option then
  453. ii_vcenter = 1
  454. else
  455. ii_vcenter = 0
  456. end if
  457. return li_ret
  458. end function
  459. public function integer of_set_margins (double ad_margin);of_set_margin_left(ad_margin)
  460. of_set_margin_right(ad_margin)
  461. of_set_margin_top(ad_margin)
  462. of_set_margin_bottom(ad_margin)
  463. return 1
  464. end function
  465. public function integer of_set_margins_lr (double ad_margin);of_set_margin_left(ad_margin)
  466. of_set_margin_right(ad_margin)
  467. return 1
  468. end function
  469. public function integer of_set_margins_tb (double ad_margin);of_set_margin_top(ad_margin)
  470. of_set_margin_bottom(ad_margin)
  471. return 1
  472. end function
  473. public function integer of_set_margin_left (double ad_margin);id_margin_left=ad_margin
  474. return 1
  475. end function
  476. public function integer of_set_margin_right (double ad_margin);id_margin_right=ad_margin
  477. return 1
  478. end function
  479. public function integer of_set_margin_top (double ad_margin);id_margin_top=ad_margin
  480. return 1
  481. end function
  482. public function integer of_set_margin_bottom (double ad_margin);id_margin_bottom=ad_margin
  483. return 1
  484. end function
  485. public function integer of_repeat_rows (unsignedinteger ai_first_row, unsignedinteger ai_last_row);ii_title_rowmin=ai_first_row
  486. ii_title_rowmax=ai_last_row
  487. return 1
  488. end function
  489. public function integer of_repeat_columns (unsignedinteger ai_first_col, unsignedinteger ai_last_col);ii_title_colmin=ai_first_col
  490. ii_title_colmax=ai_last_col
  491. return 1
  492. end function
  493. public function integer of_print_area (unsignedinteger ai_first_row, unsignedinteger ai_first_col, unsignedinteger ai_last_row, unsignedinteger ai_last_col);integer li_ret = 1
  494. ii_print_rowmin = ai_first_row
  495. ii_print_colmin = ai_first_col
  496. ii_print_rowmax = ai_last_row
  497. ii_print_colmax = ai_last_col
  498. return li_ret
  499. end function
  500. public function integer of_hide_gridlines (unsignedinteger ai_option);integer li_ret = 1
  501. choose case ai_option
  502. case 0
  503. ib_print_gridlines = true
  504. ib_screen_gridlines = true
  505. case 1
  506. ib_print_gridlines = false
  507. ib_screen_gridlines = true
  508. case else
  509. ib_print_gridlines = false
  510. ib_screen_gridlines = false
  511. end choose
  512. return li_ret
  513. end function
  514. public function integer of_print_row_col_headers (boolean ab_print_headers);ib_print_headers=ab_print_headers
  515. return 1
  516. end function
  517. public function integer of_fit_to_pages (unsignedinteger ai_width, unsignedinteger ai_height);integer li_ret =1
  518. ib_fit_page=true
  519. ii_fit_width=ai_width
  520. ii_fit_height=ai_height
  521. return li_ret
  522. end function
  523. public function integer of_add_h_pagebreak (unsignedinteger ai_hbreak);ii_hbreaks[upperbound(ii_hbreaks)+1]=ai_hbreak
  524. return 1
  525. end function
  526. public function integer of_add_v_pagebreak (unsignedinteger ai_vbreak);ii_vbreaks[upperbound(ii_vbreaks)+1]=ai_vbreak
  527. return 1
  528. end function
  529. public function integer of_set_zoom (unsignedinteger ai_scale);integer li_ret = 1
  530. if ai_scale < 10 or ai_scale > 400 then
  531. messagebox("Error", "Zoom factor outside range: 10-400", stopsign!)
  532. li_ret = -1
  533. end if
  534. if li_ret = 1 then
  535. ii_zoom = ai_scale
  536. end if
  537. return li_ret
  538. end function
  539. public function integer of_set_print_scale (unsignedinteger ai_scale);integer li_ret = 1
  540. if ai_scale < 10 or ai_scale > 400 then
  541. messagebox("Error", "Print scale scale outside range: 10-400", stopsign!)
  542. li_ret = -1
  543. end if
  544. if li_ret = 1 then
  545. ib_fit_page = false
  546. ii_print_scale = ai_scale
  547. end if
  548. return li_ret
  549. end function
  550. public function integer of_set_row_height (long al_row, double ad_height);integer li_ret = 1
  551. n_xls_format lnvo_format
  552. boolean lb_hidden
  553. setnull(lnvo_format)
  554. setnull(lb_hidden)
  555. li_ret = of_set_row(al_row, ad_height, lnvo_format, lb_hidden)
  556. return li_ret
  557. end function
  558. public function integer of_set_column_width (long al_col, double ad_width);integer li_ret = 1
  559. n_xls_format lnvo_format
  560. boolean lb_hidden
  561. ulong ll_i
  562. ll_i = invo_key_col_formats.of_get_key_index(al_col)
  563. if ll_i > 0 then
  564. lnvo_format = invo_col_formats[ll_i]
  565. else
  566. setnull(lnvo_format)
  567. end if
  568. ll_i = invo_key_col_hiddens.of_get_key_index(al_col)
  569. if ll_i > 0 then
  570. lb_hidden = ib_col_hiddens[ll_i]
  571. else
  572. setnull(lb_hidden)
  573. end if
  574. li_ret = of_set_column(al_col, al_col, ad_width, lnvo_format, lb_hidden)
  575. return li_ret
  576. end function
  577. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename, readonly unsignedinteger ai_x, readonly unsignedinteger ai_y, readonly double ad_scale_width, readonly double ad_scale_height);integer li_ret = 1
  578. long li_width
  579. long li_height
  580. long li_size
  581. blob lb_data
  582. blob lb_header
  583. li_ret = of_process_bitmap(as_bitmap_filename, li_width, li_height, li_size, lb_data)
  584. if li_ret = 1 then
  585. li_width = li_width * ad_scale_width
  586. li_height = li_height * ad_scale_height
  587. li_ret = of_position_image(ai_col, ai_row, ai_x, ai_y, li_width, li_height)
  588. end if
  589. if li_ret = 1 then
  590. lb_header = invo_sub.of_pack("v", 127) + invo_sub.of_pack("v", 8 + li_size) + invo_sub.of_pack("v", 9) + invo_sub.of_pack("v", 1) + invo_sub.of_pack("V", li_size)
  591. of_append_data(lb_header + lb_data)
  592. end if
  593. return li_ret
  594. end function
  595. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename);return of_insert_bitmap(ai_row,ai_col,as_bitmap_filename,0,0,1,1)
  596. end function
  597. public function integer of_insert_bitmap (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col, readonly string as_bitmap_filename, readonly unsignedinteger ai_x, readonly unsignedinteger ai_y);return of_insert_bitmap(ai_row,ai_col,as_bitmap_filename,ai_x,ai_y,1,1)
  598. end function
  599. public function blob of_add_continue (blob ab_data);uint li_record = 60
  600. blob lb_header
  601. blob lb_tmp
  602. ulong ll_start_pos = 1
  603. lb_tmp = blobmid(ab_data, 1, ii_limit)
  604. ab_data = blobmid(ab_data, ii_limit + 1, len(ab_data) - ii_limit)
  605. blobedit(lb_tmp, 3, invo_sub.of_pack("v", ii_limit - 4))
  606. do While len(ab_data) > ii_limit
  607. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", ii_limit)
  608. lb_tmp = lb_tmp + lb_header
  609. lb_tmp = lb_tmp + blobmid(ab_data, 1, ii_limit)
  610. ab_data = blobmid(ab_data, ii_limit + 1, len(ab_data) - ii_limit)
  611. loop
  612. if len(ab_data) > 0 then
  613. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", len(ab_data))
  614. lb_tmp = lb_tmp + lb_header
  615. lb_tmp = lb_tmp + ab_data
  616. end if
  617. return lb_tmp
  618. end function
  619. public function integer of_append_data (blob ab_data);integer li_ret = 1
  620. if len(ab_data) > ii_limit then
  621. ab_data = of_add_continue(ab_data)
  622. end if
  623. il_datasize += len(ab_data)
  624. invo_data.of_append(ab_data)
  625. return li_ret
  626. end function
  627. public function integer of_append_header (blob ab_data);integer li_ret = 1
  628. if len(ab_data) > ii_limit then
  629. ab_data = of_add_continue(ab_data)
  630. end if
  631. il_datasize += len(ab_data)
  632. invo_header.of_append(ab_data)
  633. return li_ret
  634. end function
  635. public function integer of_close ();integer li_ret = 1
  636. uint li_i
  637. uint li_cnt
  638. long ll_i
  639. of_store_bof(16)
  640. li_cnt = upperbound(invo_colinfo)
  641. if li_cnt > 0 then
  642. of_store_defcol()
  643. for li_i = li_cnt to 1 step -1
  644. of_store_colinfo(invo_colinfo[li_i])
  645. next
  646. end if
  647. of_store_print_headers()
  648. of_store_print_gridlines()
  649. of_store_gridset()
  650. of_store_Guts()
  651. of_store_default_row_height()
  652. of_store_wsbool()
  653. of_store_hbreak()
  654. of_store_vbreak()
  655. of_store_setup()
  656. of_store_protect()
  657. of_store_password()
  658. of_store_dimensions()
  659. of_store_margin_bottom()
  660. of_store_margin_top()
  661. of_store_margin_right()
  662. of_store_margin_left()
  663. of_store_vcenter()
  664. of_store_hcenter()
  665. //of_store_defcol() //2004-11-11
  666. of_store_footer()
  667. of_store_header()
  668. of_store_window2()
  669. of_store_zoom()
  670. //保存全部单元
  671. OF_Store_cells()
  672. //保存单元的合并情况
  673. OF_Store_mergecells()
  674. if not isnull(invo_panes) then
  675. if isvalid(invo_panes) then
  676. of_store_panes(invo_panes)
  677. end if
  678. end if
  679. of_store_selection(invo_selection)
  680. of_store_eof()
  681. return li_ret
  682. end function
  683. public function unsignedlong of_encode_password (string as_password);ulong ll_ret
  684. ulong ll_chars[]
  685. uint li_count
  686. uint li_i
  687. ulong ll_low
  688. ulong ll_high
  689. li_count = len(as_password)
  690. if li_count > 0 then
  691. for li_i = 1 to li_count
  692. ll_chars[li_i] = uf_bitshl(asc(mid(as_password, li_i, 1)), li_i)
  693. ll_low = uf_bitand(ll_chars[li_i], 32767)
  694. ll_high = uf_bitshr(uf_bitand(ll_chars[li_i], uf_bitshl(32767, 15)), 15)
  695. ll_chars[li_i] = uf_bitor(ll_low, ll_high)
  696. next
  697. ll_ret = 0
  698. for li_i = 1 to li_count
  699. ll_ret = uf_bitxor(ll_ret, ll_chars[li_i])
  700. next
  701. ll_ret = uf_bitxor(ll_ret, li_count)
  702. ll_ret = uf_bitxor(ll_ret, 52811)
  703. else
  704. ll_ret = 0
  705. end if
  706. return ll_ret
  707. end function
  708. public function blob of_get_data ();blob lb_tmp
  709. if isnull(ib_data) then
  710. return ib_data
  711. else
  712. lb_tmp = ib_data
  713. setnull(ib_data)
  714. return lb_tmp
  715. end if
  716. end function
  717. public function unsignedinteger of_get_excel_height (double ad_value);uint li_w1
  718. double ld_w1
  719. double ld_w2
  720. li_w1 = truncate(ad_value, 0)
  721. ld_w2 = ad_value - li_w1
  722. ld_w2 = round(ld_w2 * 4, 0) / 4
  723. return (li_w1 + ld_w2) * 20
  724. end function
  725. public function unsignedinteger of_get_excel_width (double ad_value);uint li_w1
  726. double ld_w1
  727. double ld_w2
  728. double ld_w
  729. li_w1 = truncate(ad_value, 0)
  730. ld_w2 = ad_value - li_w1
  731. if li_w1 > 0 then
  732. ld_w1 = li_w1 + 0.72
  733. else
  734. ld_w1 = 0
  735. end if
  736. if li_w1 > 0 then
  737. ld_w = ld_w1 * 256 + ld_w2 * 256
  738. else
  739. ld_w = ld_w1 * 256 + ld_w2 * 256 * 1.8
  740. end if
  741. return ld_w
  742. end function
  743. public function integer of_position_image (unsignedinteger ai_col_start, unsignedinteger ai_row_start, unsignedinteger ai_x1, unsignedinteger ai_y1, unsignedinteger ai_width, unsignedinteger ai_height);integer li_ret = 1
  744. uint li_col_end
  745. uint li_row_end
  746. uint li_x2
  747. uint li_y2
  748. //li_col_end = ai_col_start
  749. //li_row_end = ai_row_start
  750. //
  751. //if ai_x1 >= of_size_col(ai_col_start) then
  752. // ai_x1 = 0
  753. //end if
  754. //
  755. //
  756. //if ai_y1 >= of_size_row(ai_row_start) then
  757. // ai_y1 = 0
  758. //end if
  759. //
  760. //ai_width = ai_width + ai_x1 - 1
  761. //ai_height = ai_height + ai_y1 - 1
  762. //
  763. //do While ai_width >= of_size_col(li_col_end)
  764. // ai_width -= of_size_col(li_col_end)
  765. // li_col_end ++
  766. //loop
  767. //
  768. //
  769. //do While ai_height >= of_size_row(li_row_end)
  770. // ai_height -= of_size_row(li_row_end)
  771. // li_row_end ++
  772. //loop
  773. //
  774. //
  775. //if of_size_col(ai_col_start) = 0 then
  776. // return -1
  777. //end if
  778. //
  779. //
  780. //if of_size_col(li_col_end) = 0 then
  781. // return -1
  782. //end if
  783. //
  784. //
  785. //if of_size_row(ai_row_start) = 0 then
  786. // return -1
  787. //end if
  788. //
  789. //
  790. //if of_size_row(li_row_end) = 0 then
  791. // return -1
  792. //end if
  793. //
  794. //ai_x1 = ai_x1 / of_size_col(ai_col_start) * 1024
  795. //ai_y1 = ai_y1 / of_size_row(ai_row_start) * 256
  796. //li_x2 = ai_width / of_size_col(li_col_end) * 1024
  797. //li_y2 = ai_height / of_size_row(li_row_end) * 256
  798. //li_ret = of_store_obj_picture(ai_col_start, ai_x1, ai_row_start, ai_y1, li_col_end, li_x2, li_row_end, li_y2)
  799. return li_ret
  800. end function
  801. public function integer of_process_bitmap (readonly string as_bitmap_filename, ref long al_width, ref long al_height, ref long al_size, ref blob ab_data);integer li_ret = 1
  802. integer li_file
  803. blob lb_data_item
  804. blob lb_data
  805. ulong ll_size
  806. uint li_planes
  807. uint li_bitcount
  808. ulong ll_compression
  809. blob lb_header
  810. li_file = fileopen(as_bitmap_filename, streammode!, read!, lockwrite!)
  811. if li_file <> -1 then
  812. setnull(lb_data)
  813. do While fileread(li_file, lb_data_item) > 0
  814. if isnull(lb_data) then
  815. lb_data = lb_data_item
  816. else
  817. lb_data = lb_data + lb_data_item
  818. end if
  819. loop
  820. if isnull(lb_data) then
  821. li_ret = -1
  822. end if
  823. fileclose(li_file)
  824. else
  825. li_ret = -1
  826. messagebox("Error", "Couldn't open " + as_bitmap_filename, stopsign!)
  827. end if
  828. if li_ret = 1 then
  829. if len(lb_data) <= 54 then
  830. li_ret = -1
  831. messagebox("Error", as_bitmap_filename + " doesn't contain enough data", stopsign!)
  832. end if
  833. end if
  834. if li_ret = 1 then
  835. if string(blobmid(lb_data, 1, 2)) <> "BM" then
  836. li_ret = -1
  837. messagebox("Error", as_bitmap_filename + " doesn't appear to to be a valid bitmap image", stopsign!)
  838. end if
  839. end if
  840. if li_ret = 1 then
  841. ll_size = long(blobmid(lb_data, 3, 4))
  842. ll_size -= 54 - 12
  843. al_width = long(blobmid(lb_data, 19, 4))
  844. al_height = long(blobmid(lb_data, 23, 4))
  845. if al_width > 65535 then
  846. li_ret = -1
  847. messagebox("Error", as_bitmap_filename + ": largest image width supported is 65535", stopsign!)
  848. end if
  849. end if
  850. if li_ret = 1 then
  851. if al_height > 65535 then
  852. li_ret = -1
  853. messagebox("Error", as_bitmap_filename + ": largest image height supported is 65535", stopsign!)
  854. end if
  855. end if
  856. if li_ret = 1 then
  857. li_planes = integer(blobmid(lb_data, 27, 2))
  858. li_bitcount = integer(blobmid(lb_data, 29, 2))
  859. if li_bitcount <> 24 then
  860. li_ret = -1
  861. messagebox("Error", as_bitmap_filename + " isn't a 24bit true color bitmap", stopsign!)
  862. end if
  863. end if
  864. if li_ret = 1 then
  865. if li_planes <> 1 then
  866. li_ret = -1
  867. messagebox("Error", as_bitmap_filename + ": only 1 plane supported in bitmap image", stopsign!)
  868. end if
  869. end if
  870. if li_ret = 1 then
  871. ll_compression = long(blobmid(lb_data, 31, 4))
  872. if ll_compression <> 0 then
  873. li_ret = -1
  874. messagebox("Error", as_bitmap_filename + ": compression not supported in bitmap image", stopsign!)
  875. end if
  876. end if
  877. if li_ret = 1 then
  878. lb_header = invo_sub.of_pack("V", 12) + invo_sub.of_pack("v", al_width) + invo_sub.of_pack("v", al_height) + invo_sub.of_pack("v", 1) + invo_sub.of_pack("v", 24)
  879. ab_data = lb_header + blobmid(lb_data, 55, len(lb_data) - 55 + 1)
  880. al_size = ll_size
  881. end if
  882. return li_ret
  883. end function
  884. public function integer of_set_row (unsignedinteger ai_row, double ad_height, n_xls_format anvo_format, boolean ab_hidden);integer li_ret = 1
  885. uint li_record = 520
  886. uint li_length = 16
  887. uint li_colmic
  888. uint li_colmac
  889. uint li_irwmac
  890. uint li_reserved
  891. uint li_grbit = 320
  892. uint li_ixfe = 15
  893. uint li_miyrw = 255
  894. blob lb_header
  895. blob lb_data
  896. ulong ll_i
  897. boolean lb_format_undef
  898. if not isnull(anvo_format) then
  899. if isvalid(anvo_format) then
  900. li_ixfe = invo_workbook.of_reg_format(anvo_format)
  901. li_grbit = li_grbit + 128
  902. else
  903. lb_format_undef = true
  904. end if
  905. else
  906. lb_format_undef = true
  907. end if
  908. if lb_format_undef then
  909. ll_i = invo_key_row_formats.of_get_key_index(ai_row)
  910. if ll_i > 0 then
  911. li_ixfe = invo_workbook.of_reg_format(invo_row_formats[ll_i])
  912. li_grbit = li_grbit + 128
  913. end if
  914. end if
  915. if not isnull(ad_height) then
  916. li_miyrw = of_get_excel_height(ad_height)
  917. else
  918. ll_i = invo_key_row_sizes.of_get_key_index(ai_row)
  919. if ll_i > 0 then
  920. li_miyrw = id_row_sizes[ll_i] * 20
  921. end if
  922. end if
  923. if isnull(ab_hidden) then
  924. ll_i = invo_key_row_hiddens.of_get_key_index(ai_row)
  925. if ll_i > 0 then
  926. if ib_row_hiddens[ll_i] then
  927. li_grbit = li_grbit + 32
  928. end if
  929. end if
  930. elseif ab_hidden then
  931. li_grbit = li_grbit + 32
  932. end if
  933. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  934. lb_data = invo_sub.of_pack("v", ai_row) + invo_sub.of_pack("v", li_colmic) + invo_sub.of_pack("v", li_colmac) + invo_sub.of_pack("v", li_miyrw) + invo_sub.of_pack("v", li_irwmac) + invo_sub.of_pack("v", li_reserved) + invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("v", li_ixfe)
  935. of_append_data(lb_header + lb_data)
  936. if not isnull(ab_hidden) then
  937. ll_i = invo_key_row_hiddens.of_get_key_index(ai_row)
  938. if ll_i = 0 then
  939. ll_i = invo_key_row_hiddens.of_add_key(ai_row)
  940. end if
  941. ib_row_hiddens[ll_i] = ab_hidden
  942. end if
  943. if not isnull(ad_height) then
  944. ll_i = invo_key_row_sizes.of_get_key_index(ai_row)
  945. if ll_i = 0 then
  946. ll_i = invo_key_row_sizes.of_add_key(ai_row)
  947. end if
  948. id_row_sizes[ll_i] = ad_height
  949. end if
  950. if not isnull(anvo_format) then
  951. if isvalid(anvo_format) then
  952. ll_i = invo_key_row_formats.of_get_key_index(ai_row)
  953. if ll_i = 0 then
  954. ll_i = invo_key_row_formats.of_add_key(ai_row)
  955. end if
  956. invo_row_formats[ll_i] = anvo_format
  957. end if
  958. end if
  959. return li_ret
  960. end function
  961. public function integer of_write_data (olestream astr_book);integer li_ret = 1
  962. invo_header.of_write(astr_book)
  963. invo_data.of_write(astr_book)
  964. return li_ret
  965. end function
  966. public function integer of_sort_pagebreaks (ref unsignedinteger ai_page_breaks[]);integer li_ret = 1
  967. n_associated_ulong_srv invo_key_breaks
  968. uint li_cnt
  969. uint li_i
  970. ulong ll_ind
  971. uint li_new[]
  972. invo_key_breaks = create n_associated_ulong_srv
  973. li_cnt = upperbound(ai_page_breaks)
  974. for li_i = 1 to li_cnt
  975. if ai_page_breaks[li_i] > 0 then
  976. ll_ind = invo_key_breaks.of_get_key_index(ai_page_breaks[li_i])
  977. if ll_ind = 0 then
  978. invo_key_breaks.of_add_key(ai_page_breaks[li_i])
  979. end if
  980. end if
  981. next
  982. invo_key_breaks.of_sort_keys()
  983. li_cnt = invo_key_breaks.of_get_keys_count()
  984. for li_i = 1 to li_cnt
  985. li_new[li_i] = invo_key_breaks.of_get_key(li_i)
  986. next
  987. ai_page_breaks = li_new
  988. return li_ret
  989. end function
  990. public function integer of_store_bof (unsignedinteger ai_type);integer li_ret = 1
  991. uint li_record = 2057
  992. uint li_length = 16
  993. blob lb_header
  994. blob lb_data
  995. uint li_version
  996. ulong ll_history_flag = 16449
  997. ulong ll_lowest_version = 262
  998. uint li_build = 6319
  999. uint li_year = 1997
  1000. li_version = invo_workbook.ii_biff_version
  1001. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1002. lb_data = invo_sub.of_pack("v", li_version) + invo_sub.of_pack("v", ai_type) + invo_sub.of_pack("v", li_build) + invo_sub.of_pack("v", li_year) + invo_sub.of_pack("V", ll_history_flag) + invo_sub.of_pack("V", ll_lowest_version)
  1003. of_append_header(lb_header + lb_data)
  1004. return li_ret
  1005. end function
  1006. public function integer of_store_colinfo (n_xls_colinfo anvo_colinfo);integer li_ret = 1
  1007. uint li_record = 125
  1008. uint li_length = 11
  1009. blob lb_header
  1010. blob lb_data
  1011. uint li_coldx
  1012. uint li_ixfe = 15
  1013. uint li_grbit
  1014. uint li_reserved
  1015. n_xls_format lnvo_format
  1016. li_coldx = of_get_excel_width(anvo_colinfo.id_width)
  1017. if anvo_colinfo.ib_hidden then
  1018. li_grbit = 1
  1019. end if
  1020. if not isnull(anvo_colinfo.invo_format) then
  1021. if isvalid(anvo_colinfo.invo_format) then
  1022. lnvo_format = anvo_colinfo.invo_format
  1023. li_ixfe = invo_workbook.of_get_xf(lnvo_format)
  1024. end if
  1025. end if
  1026. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1027. lb_data = invo_sub.of_pack("v", anvo_colinfo.ii_firstcol) + invo_sub.of_pack("v", anvo_colinfo.ii_lastcol) + invo_sub.of_pack("v", li_coldx) + invo_sub.of_pack("v", li_ixfe) + invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("C", li_reserved)
  1028. of_append_header(lb_header + lb_data)
  1029. return li_ret
  1030. end function
  1031. public function integer of_store_defcol ();integer li_ret = 1
  1032. uint li_record = 85
  1033. uint li_length = 2
  1034. blob lb_header
  1035. blob lb_data
  1036. uint li_colwidth = 8
  1037. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1038. lb_data = invo_sub.of_pack("v", li_colwidth)
  1039. of_append_header(lb_header + lb_data)
  1040. return li_ret
  1041. end function
  1042. public function integer of_store_dimensions ();integer li_ret = 1
  1043. uint li_record = 512
  1044. uint li_length = 14
  1045. uint li_row_min
  1046. uint li_row_max
  1047. uint li_col_min
  1048. uint li_col_max
  1049. uint li_reserved
  1050. blob lb_header
  1051. blob lb_data
  1052. if ib_dim_changed then
  1053. li_row_min = il_dim_rowmin
  1054. li_row_max = il_dim_rowmax + 1
  1055. li_col_min = il_dim_colmin
  1056. li_col_max = il_dim_colmax + 1
  1057. else
  1058. li_row_min = 0
  1059. li_row_max = 0
  1060. li_col_min = 0
  1061. li_col_max = 256
  1062. end if
  1063. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1064. lb_data = invo_sub.of_pack("V", li_row_min) + invo_sub.of_pack("V", li_row_max) + invo_sub.of_pack("v", li_col_min) + invo_sub.of_pack("v", li_col_max) + invo_sub.of_pack("v", li_reserved)
  1065. of_append_header(lb_header + lb_data)
  1066. return li_ret
  1067. end function
  1068. public function integer of_store_eof ();integer li_ret = 1
  1069. uint li_record = 10
  1070. uint li_length
  1071. blob lb_header
  1072. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1073. of_append_data(lb_header)
  1074. return li_ret
  1075. end function
  1076. public function integer of_store_externcount (unsignedinteger ai_count);integer li_ret = 1
  1077. uint li_record = 22
  1078. uint li_length = 2
  1079. blob lb_header
  1080. blob lb_data
  1081. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1082. lb_data = invo_sub.of_pack("v", ai_count)
  1083. of_append_header(lb_header + lb_data)
  1084. return li_ret
  1085. end function
  1086. public function integer of_store_externsheet (string as_sheetname);integer li_ret = 1
  1087. uint li_record = 23
  1088. uint li_length
  1089. blob lb_header
  1090. blob lb_data
  1091. uint li_cch
  1092. uint li_rgch
  1093. if is_worksheetname = as_sheetname then
  1094. as_sheetname = ""
  1095. li_length = 2
  1096. li_cch = 1
  1097. li_rgch = 2
  1098. else
  1099. li_length = 2 + len(as_sheetname)
  1100. li_cch = len(as_sheetname)
  1101. li_rgch = 3
  1102. end if
  1103. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1104. lb_data = invo_sub.of_pack("C", li_cch) + invo_sub.of_pack("C", li_rgch)
  1105. if len(as_sheetname) > 0 then
  1106. lb_data = lb_data + blob(as_sheetname)
  1107. end if
  1108. of_append_header(lb_header + lb_data)
  1109. return li_ret
  1110. end function
  1111. public function integer of_store_footer ();integer li_ret = 1
  1112. uint li_record = 21
  1113. uint li_length
  1114. blob lb_header
  1115. blob lb_data
  1116. uint li_cch
  1117. li_cch = len(ib_footer) / 2
  1118. li_length = 3 + li_cch * 2
  1119. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1120. lb_data = invo_sub.of_pack("v", li_cch) + invo_sub.of_pack("C", 1) + ib_footer
  1121. of_append_data(lb_header + lb_data)
  1122. return li_ret
  1123. end function
  1124. public function integer of_store_gridset ();integer li_ret = 1
  1125. uint li_record = 130
  1126. uint li_length = 2
  1127. blob lb_header
  1128. blob lb_data
  1129. uint li_fgridset
  1130. if not ib_print_gridlines then
  1131. li_fgridset = 1
  1132. end if
  1133. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1134. lb_data = invo_sub.of_pack("v", li_fgridset)
  1135. of_append_header(lb_header + lb_data)
  1136. return li_ret
  1137. end function
  1138. public function integer of_store_hbreak ();integer li_ret = 1
  1139. uint li_tmp[]
  1140. uint li_record = 27
  1141. uint li_length
  1142. blob lb_header
  1143. blob lb_data
  1144. uint li_cbrk
  1145. uint li_i
  1146. li_tmp = ii_hbreaks
  1147. of_sort_pagebreaks(li_tmp)
  1148. li_cbrk = upperbound(li_tmp)
  1149. if li_cbrk = 0 then
  1150. return li_ret
  1151. end if
  1152. li_length = li_cbrk * 6 + 2
  1153. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1154. lb_data = invo_sub.of_pack("v", li_cbrk)
  1155. for li_i = 1 to li_cbrk
  1156. lb_data = lb_data + invo_sub.of_pack("v", li_tmp[li_i]) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 255)
  1157. next
  1158. of_append_header(lb_header + lb_data)
  1159. return li_ret
  1160. end function
  1161. public function integer of_store_hcenter ();integer li_ret = 1
  1162. uint li_record = 131
  1163. uint li_length = 2
  1164. blob lb_header
  1165. blob lb_data
  1166. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1167. lb_data = invo_sub.of_pack("v", ii_hcenter)
  1168. of_append_data(lb_header + lb_data)
  1169. return li_ret
  1170. end function
  1171. protected function integer of_store_header ();integer li_ret = 1
  1172. uint li_record = 20
  1173. uint li_length
  1174. blob lb_header
  1175. blob lb_data
  1176. uint li_cch
  1177. li_cch = len(ib_header) / 2
  1178. li_length = 3 + li_cch * 2
  1179. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1180. lb_data = invo_sub.of_pack("v", li_cch) + invo_sub.of_pack("C", 1) + ib_header
  1181. of_append_data(lb_header + lb_data)
  1182. return li_ret
  1183. end function
  1184. protected function integer of_store_margin_bottom ();integer li_ret = 1
  1185. uint li_record = 41
  1186. uint li_length = 8
  1187. blob lb_header
  1188. blob lb_data
  1189. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1190. lb_data = invo_sub.of_pack("d", id_margin_bottom)
  1191. of_append_data(lb_header + lb_data)
  1192. return li_ret
  1193. end function
  1194. protected function integer of_store_margin_left ();integer li_ret = 1
  1195. uint li_record = 38
  1196. uint li_length = 8
  1197. blob lb_header
  1198. blob lb_data
  1199. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1200. lb_data = invo_sub.of_pack("d", id_margin_left)
  1201. of_append_data(lb_header + lb_data)
  1202. return li_ret
  1203. end function
  1204. public function integer of_store_margin_right ();integer li_ret = 1
  1205. uint li_record = 39
  1206. uint li_length = 8
  1207. blob lb_header
  1208. blob lb_data
  1209. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1210. lb_data = invo_sub.of_pack("d", id_margin_right)
  1211. of_append_data(lb_header + lb_data)
  1212. return li_ret
  1213. end function
  1214. protected function integer of_store_margin_top ();integer li_ret = 1
  1215. uint li_record = 40
  1216. uint li_length = 8
  1217. blob lb_header
  1218. blob lb_data
  1219. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1220. lb_data = invo_sub.of_pack("d", id_margin_top)
  1221. of_append_data(lb_header + lb_data)
  1222. return li_ret
  1223. end function
  1224. public function integer of_store_obj_picture (unsignedinteger ai_col_start, unsignedinteger ai_x1, unsignedinteger ai_row_start, unsignedinteger ai_y1, unsignedinteger ai_col_end, unsignedinteger ai_x2, unsignedinteger ai_row_end, unsignedinteger ai_y2);integer li_ret = 1
  1225. blob lb_header
  1226. lb_header = invo_sub.of_pack("v", 93) + invo_sub.of_pack("v", 60) + invo_sub.of_pack("V", 1) + invo_sub.of_pack("v", 8) + invo_sub.of_pack("v", 1) + invo_sub.of_pack("v", 1556) + invo_sub.of_pack("v", ai_col_start) + invo_sub.of_pack("v", ai_x1) + invo_sub.of_pack("v", ai_row_start) + invo_sub.of_pack("v", ai_y1) + invo_sub.of_pack("v", ai_col_end) + invo_sub.of_pack("v", ai_x2) + invo_sub.of_pack("v", ai_row_end) + invo_sub.of_pack("v", ai_y2) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("V", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("C", 9) + invo_sub.of_pack("C", 9) + invo_sub.of_pack("C", 0) + invo_sub.of_pack("C", 0) + invo_sub.of_pack("C", 8) + invo_sub.of_pack("C", 255) + invo_sub.of_pack("C", 1) + invo_sub.of_pack("C", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("V", 9) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 1) + invo_sub.of_pack("V", 0)
  1227. of_append_data(lb_header)
  1228. return li_ret
  1229. end function
  1230. public function integer of_store_panes (n_xls_panes anvo_panes);integer li_ret = 1
  1231. uint li_record = 65
  1232. uint li_length = 10
  1233. blob lb_header
  1234. blob lb_data
  1235. uint li_y
  1236. uint li_x
  1237. uint li_rwtop
  1238. uint li_colleft
  1239. uint li_pnnact
  1240. if ib_frozen then
  1241. li_y = anvo_panes.id_y
  1242. li_x = anvo_panes.id_x
  1243. if isnull(anvo_panes.ii_rowtop) then
  1244. li_rwtop = li_y
  1245. else
  1246. li_rwtop = anvo_panes.ii_rowtop
  1247. end if
  1248. if isnull(anvo_panes.ii_colleft) then
  1249. li_colleft = li_x
  1250. else
  1251. li_colleft = anvo_panes.ii_colleft
  1252. end if
  1253. else
  1254. if isnull(anvo_panes.ii_rowtop) then
  1255. li_rwtop = 0
  1256. else
  1257. li_rwtop = anvo_panes.ii_rowtop
  1258. end if
  1259. if isnull(anvo_panes.ii_colleft) then
  1260. li_colleft = 0
  1261. else
  1262. li_colleft = anvo_panes.ii_colleft
  1263. end if
  1264. li_y = 20 * anvo_panes.id_y + 255
  1265. li_x = 113.879 * anvo_panes.id_x + 390
  1266. end if
  1267. if li_x <> 0 and li_y <> 0 then
  1268. li_pnnact = 0
  1269. end if
  1270. if li_x <> 0 and li_y = 0 then
  1271. li_pnnact = 1
  1272. end if
  1273. if li_x = 0 and li_y <> 0 then
  1274. li_pnnact = 2
  1275. end if
  1276. if li_x = 0 and li_y = 0 then
  1277. li_pnnact = 3
  1278. end if
  1279. ii_active_pane = li_pnnact
  1280. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1281. lb_data = invo_sub.of_pack("v", li_x) + invo_sub.of_pack("v", li_y) + invo_sub.of_pack("v", li_rwtop) + invo_sub.of_pack("v", li_colleft) + invo_sub.of_pack("v", li_pnnact)
  1282. of_append_data(lb_header + lb_data)
  1283. return li_ret
  1284. end function
  1285. public function integer of_store_password ();integer li_ret = 1
  1286. uint li_record = 19
  1287. uint li_length = 2
  1288. blob lb_header
  1289. blob lb_data
  1290. uint li_wpassword
  1291. if not ib_protect then
  1292. return li_ret
  1293. end if
  1294. li_wpassword = of_encode_password(is_password)
  1295. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1296. lb_data = invo_sub.of_pack("v", li_wpassword)
  1297. of_append_header(lb_header + lb_data)
  1298. return li_ret
  1299. end function
  1300. public function integer of_store_print_gridlines ();integer li_ret = 1
  1301. uint li_record = 43
  1302. uint li_length = 2
  1303. blob lb_header
  1304. blob lb_data
  1305. uint li_fprintgrid
  1306. if ib_print_gridlines then
  1307. li_fprintgrid = 1
  1308. end if
  1309. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1310. lb_data = invo_sub.of_pack("v", li_fprintgrid)
  1311. of_append_header(lb_header + lb_data)
  1312. return li_ret
  1313. end function
  1314. public function integer of_store_print_headers ();integer li_ret = 1
  1315. uint li_record = 42
  1316. uint li_length = 2
  1317. blob lb_header
  1318. blob lb_data
  1319. uint li_fprintrwcol
  1320. if ib_print_headers then
  1321. li_fprintrwcol = 1
  1322. end if
  1323. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1324. lb_data = invo_sub.of_pack("v", li_fprintrwcol)
  1325. of_append_header(lb_header + lb_data)
  1326. return li_ret
  1327. end function
  1328. protected function integer of_store_protect ();integer li_ret = 1
  1329. uint li_record = 18
  1330. uint li_length = 2
  1331. blob lb_header
  1332. blob lb_data
  1333. uint li_flock
  1334. if not ib_protect then
  1335. return li_ret
  1336. end if
  1337. li_flock = 1
  1338. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1339. lb_data = invo_sub.of_pack("v", li_flock)
  1340. of_append_header(lb_header + lb_data)
  1341. return li_ret
  1342. end function
  1343. public function integer of_store_selection (n_xls_selection anvo_selection);integer li_ret = 1
  1344. uint li_record = 29
  1345. uint li_length = 15
  1346. blob lb_header
  1347. blob lb_data
  1348. uint li_pnn
  1349. uint li_irefact
  1350. uint li_cref = 1
  1351. uint li_rwact
  1352. uint li_colact
  1353. uint li_rwfirst
  1354. uint li_rwlast
  1355. uint li_colfirst
  1356. uint li_collast
  1357. li_pnn = ii_active_pane
  1358. li_rwact = anvo_selection.ii_first_row
  1359. li_colact = anvo_selection.ii_first_col
  1360. if anvo_selection.ii_first_row > anvo_selection.ii_last_row then
  1361. li_rwfirst = anvo_selection.ii_last_row
  1362. li_rwlast = anvo_selection.ii_first_row
  1363. else
  1364. li_rwfirst = anvo_selection.ii_first_row
  1365. li_rwlast = anvo_selection.ii_last_row
  1366. end if
  1367. if anvo_selection.ii_first_col > anvo_selection.ii_last_col then
  1368. li_colfirst = anvo_selection.ii_last_col
  1369. li_collast = anvo_selection.ii_first_col
  1370. else
  1371. li_colfirst = anvo_selection.ii_first_col
  1372. li_collast = anvo_selection.ii_last_col
  1373. end if
  1374. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1375. lb_data = invo_sub.of_pack("C", li_pnn) + invo_sub.of_pack("v", li_rwact) + invo_sub.of_pack("v", li_colact) + invo_sub.of_pack("v", li_irefact) + invo_sub.of_pack("v", li_cref) + invo_sub.of_pack("v", li_rwfirst) + invo_sub.of_pack("v", li_rwlast) + invo_sub.of_pack("C", li_colfirst) + invo_sub.of_pack("C", li_collast)
  1376. of_append_data(lb_header + lb_data)
  1377. return li_ret
  1378. end function
  1379. public function integer of_store_setup ();integer li_ret = 1
  1380. uint li_record = 161
  1381. uint li_length = 34
  1382. blob lb_header
  1383. blob lb_data
  1384. uint li_ipagestart = 1
  1385. uint li_grbit
  1386. uint li_ires = 600
  1387. uint li_ivres = 600
  1388. uint li_icopies = 1
  1389. uint li_flefttoright
  1390. uint li_flandscape
  1391. uint li_fnopls
  1392. uint li_fnocolor
  1393. uint li_fdraft
  1394. uint li_fnotes
  1395. uint li_fnoorient
  1396. uint li_fusepage
  1397. //2004-11-11 是否单色打印
  1398. IF ib_Print_NoColor Then
  1399. li_fnocolor=1
  1400. ELSE
  1401. li_fnocolor=0
  1402. END IF
  1403. li_flandscape = ii_orientation
  1404. li_grbit = li_flefttoright
  1405. li_grbit = li_grbit + li_flandscape * 2
  1406. li_grbit = li_grbit + li_fnopls * 4
  1407. li_grbit = li_grbit + li_fnocolor * 8
  1408. li_grbit = li_grbit + li_fdraft * 16
  1409. li_grbit = li_grbit + li_fnotes * 32
  1410. li_grbit = li_grbit + li_fnoorient * 64
  1411. li_grbit = li_grbit + li_fusepage * 128
  1412. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1413. lb_data = invo_sub.of_pack("v", ii_paper_size) + invo_sub.of_pack("v", ii_print_scale) + invo_sub.of_pack("v", li_ipagestart) + invo_sub.of_pack("v", ii_fit_width) + invo_sub.of_pack("v", ii_fit_height) + invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("v", li_ires) + invo_sub.of_pack("v", li_ivres) + invo_sub.of_pack("d", id_margin_head) + invo_sub.of_pack("d", id_margin_foot) + invo_sub.of_pack("v", li_icopies)
  1414. of_append_header(lb_header + lb_data)
  1415. return li_ret
  1416. end function
  1417. public function integer of_store_vbreak ();integer li_ret = 1
  1418. uint li_tmp[]
  1419. uint li_record = 26
  1420. uint li_length
  1421. blob lb_header
  1422. blob lb_data
  1423. uint li_cbrk
  1424. uint li_i
  1425. li_tmp = ii_vbreaks
  1426. of_sort_pagebreaks(li_tmp)
  1427. li_cbrk = upperbound(li_tmp)
  1428. if li_cbrk = 0 then
  1429. return li_ret
  1430. end if
  1431. li_length = li_cbrk * 6 + 2
  1432. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1433. lb_data = invo_sub.of_pack("v", li_cbrk)
  1434. for li_i = 1 to li_cbrk
  1435. lb_data = lb_data + invo_sub.of_pack("v", li_tmp[li_i]) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 65535)
  1436. next
  1437. of_append_header(lb_header + lb_data)
  1438. return li_ret
  1439. end function
  1440. public function integer of_store_vcenter ();integer li_ret = 1
  1441. uint li_record = 132
  1442. uint li_length = 2
  1443. blob lb_header
  1444. blob lb_data
  1445. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1446. lb_data = invo_sub.of_pack("v", ii_vcenter)
  1447. of_append_data(lb_header + lb_data)
  1448. return li_ret
  1449. end function
  1450. public function integer of_store_window2 ();integer li_ret = 1
  1451. uint li_record = 574
  1452. uint li_length = 18
  1453. blob lb_header
  1454. blob lb_data
  1455. uint li_grbit = 182
  1456. uint li_rwtop
  1457. uint li_colleft
  1458. integer li_fdspfmla
  1459. integer li_fdspgrid
  1460. integer li_fdsprwcol = 1
  1461. integer li_ffrozen
  1462. integer li_fdspzeros = 1
  1463. integer li_fdefaulthdr = 1
  1464. integer li_farabic
  1465. integer li_fdspguts = 1
  1466. integer li_ffrozennosplit
  1467. integer li_fselected
  1468. integer li_fpaged = 1
  1469. if ib_screen_gridlines then
  1470. li_fdspgrid = 1
  1471. end if
  1472. if ib_frozen then
  1473. li_ffrozen = 1
  1474. end if
  1475. if ib_selected then
  1476. li_fselected = 1
  1477. end if
  1478. li_grbit = li_fdspfmla
  1479. li_grbit = li_grbit + li_fdspgrid * 2
  1480. li_grbit = li_grbit + li_fdsprwcol * 4
  1481. li_grbit = li_grbit + li_ffrozen * 8
  1482. li_grbit = li_grbit + li_fdspzeros * 16
  1483. li_grbit = li_grbit + li_fdefaulthdr * 32
  1484. li_grbit = li_grbit + li_farabic * 64
  1485. li_grbit = li_grbit + li_fdspguts * 128
  1486. li_grbit = li_grbit + li_ffrozennosplit * 256
  1487. li_grbit = li_grbit + li_fselected * 512
  1488. li_grbit = li_grbit + li_fpaged * 1024
  1489. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1490. lb_data = invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("v", li_rwtop) + invo_sub.of_pack("v", li_colleft) + invo_sub.of_pack("v", 64) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("V", 0)
  1491. of_append_data(lb_header + lb_data)
  1492. return li_ret
  1493. end function
  1494. public function integer of_store_wsbool ();integer li_ret = 1
  1495. uint li_record = 129
  1496. uint li_length = 2
  1497. blob lb_header
  1498. blob lb_data
  1499. uint li_grbit
  1500. if ib_fit_page then
  1501. li_grbit = 1473
  1502. else
  1503. li_grbit = 1217
  1504. end if
  1505. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1506. lb_data = invo_sub.of_pack("v", li_grbit)
  1507. of_append_header(lb_header + lb_data)
  1508. return li_ret
  1509. end function
  1510. public function integer of_store_zoom ();integer li_ret = 1
  1511. uint li_record = 160
  1512. uint li_length = 4
  1513. blob lb_header
  1514. blob lb_data
  1515. if ii_zoom = 100 then
  1516. return li_ret
  1517. end if
  1518. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1519. lb_data = invo_sub.of_pack("v", ii_zoom) + invo_sub.of_pack("v", 100)
  1520. of_append_data(lb_header + lb_data)
  1521. return li_ret
  1522. end function
  1523. public function integer of_store_cells ();Blob lb_Header_str
  1524. Blob lb_Header_double
  1525. Blob lb_Header_FormatOnly
  1526. Blob lb_Data
  1527. uint li ,lj
  1528. uint li_2,lj_2
  1529. uint li_endrow,li_endcol
  1530. uint li_xf
  1531. uint li_rowcount
  1532. int li_Ret
  1533. n_xls_cell lnvo_cell
  1534. n_xls_cell lnvo_cell_Tmp
  1535. Boolean lb_MergeCell
  1536. lb_Header_str=invo_sub.of_pack("v", 253) + invo_sub.of_pack("v", 10)
  1537. lb_Header_double=invo_sub.of_pack("v", 515) + invo_sub.of_pack("v", 14)
  1538. lb_Header_FormatOnly = invo_sub.of_pack("v", 513) + invo_sub.of_pack("v", 6)
  1539. li_rowcount=upperbound(inv_rows)
  1540. for li= 1 To li_rowcount
  1541. if isvalid(inv_rows[li] )=false or isnull(inv_rows[li]) then
  1542. continue
  1543. end if
  1544. for lj=1 to inv_rows[li].ii_MaxCol
  1545. lnvo_cell= inv_rows[li].invo_cells[lj]
  1546. if isvalid(lnvo_cell) then
  1547. if Not lnvo_cell.ib_Empty then
  1548. if lnvo_cell.EndRow>lnvo_Cell.Row OR lnvo_Cell.EndCol>lnvo_Cell.Col Then
  1549. lb_MergeCell=True
  1550. IF of_isValidCell(lnvo_cell.EndRow,lnvo_Cell.EndCol,ref lnvo_cell_Tmp) Then
  1551. lnvo_Cell.invo_Format.ii_Right=lnvo_cell_Tmp.invo_Format.ii_Right
  1552. lnvo_Cell.invo_Format.ii_Right_color=lnvo_cell_Tmp.invo_Format.ii_Right_color
  1553. lnvo_Cell.invo_Format.ii_bottom=lnvo_cell_Tmp.invo_Format.ii_bottom
  1554. lnvo_Cell.invo_Format.ii_bottom_color=lnvo_cell_Tmp.invo_Format.ii_bottom_color
  1555. //2004-11-15
  1556. lnvo_Cell.ii_xf = 0
  1557. End IF
  1558. ELSE
  1559. lb_MergeCell=False
  1560. END IF
  1561. //需要进行这样的处理,否则由于合并单元内的数据类型不一致,导致在Excel不能正常显示单元格式
  1562. IF lb_MergeCell Then
  1563. IF lnvo_Cell.ii_xf =0 Then
  1564. lnvo_Cell.ii_xf =invo_WorkBook.OF_Reg_Format(lnvo_Cell.invo_Format)+14
  1565. END IF
  1566. for li_2= lnvo_Cell.Row To lnvo_Cell.EndRow
  1567. For lj_2=lnvo_Cell.Col To lnvo_Cell.EndCol
  1568. IF li_2=lnvo_cell.row AND lj_2=lnvo_cell.Col Then
  1569. Continue
  1570. END IF
  1571. IF of_isValidCell(li_2,lj_2,ref lnvo_cell_Tmp) Then
  1572. // 2004-11-15
  1573. IF lnvo_Cell_tmp.is_Value<>"" AND lnvo_Cell.is_CellType='S' Then
  1574. lnvo_cell.is_Value+=" "+ lnvo_Cell_tmp.is_Value
  1575. END IF
  1576. lnvo_cell_Tmp.ib_Empty=True
  1577. END IF
  1578. IF lnvo_Cell.invo_Format.is_num_format<>"" Then
  1579. lb_data = lnvo_Cell.OF_GetFormatOnly( li_2,lj_2)
  1580. of_append_data(lb_Header_FormatOnly + lb_data)
  1581. END IF
  1582. Next
  1583. next
  1584. END IF
  1585. li_Ret= lnvo_cell.OF_GetData(Ref lb_Data)
  1586. IF li_Ret =1 Then
  1587. of_append_data(lb_Header_FormatOnly + lb_data)
  1588. ELSEIF li_Ret =2 Then
  1589. of_append_data(lb_Header_str + lb_data)
  1590. ELSE
  1591. of_append_data(lb_Header_double + lb_data)
  1592. END IF
  1593. end if
  1594. // 释放对象
  1595. Destroy lnvo_cell
  1596. end if
  1597. next
  1598. next
  1599. Return 1
  1600. end function
  1601. public function n_xls_cell of_getcell (unsignedinteger row, unsignedinteger col);/*-----------------------------------------------------------------------------------
  1602. 参数: Row 行号
  1603. Col 列号
  1604. -----------------------------------------------------------------------------------*/
  1605. n_xls_Cell lnvo_Cell
  1606. n_xls_Row lnvo_row
  1607. IF Row>UpperBound(inv_Rows) Then
  1608. lnvo_Row=Create n_xls_row
  1609. lnvo_Row.invo_WorkSheet = This
  1610. inv_Rows[Row]=lnvo_row
  1611. ELSE
  1612. lnvo_row=inv_Rows[Row]
  1613. IF IsValid(lnvo_Row)=False OR IsNull(lnvo_Row) Then
  1614. lnvo_Row=Create n_xls_row
  1615. lnvo_Row.invo_WorkSheet = This
  1616. inv_Rows[Row]=lnvo_row
  1617. END IF
  1618. END IF
  1619. IF Col> lnvo_row.ii_MaxCol Then
  1620. lnvo_row.ii_MaxCol=Col
  1621. END IF
  1622. //以便重新设置单元
  1623. lnvo_row.OF_SetRow(Row)
  1624. lnvo_Row.invo_Cells[Col].ib_Empty=False
  1625. lnvo_Cell=lnvo_Row.invo_Cells[Col]
  1626. Return lnvo_Cell
  1627. end function
  1628. public subroutine of_reg_cellformat (n_xls_cell anvo_firstcell);
  1629. end subroutine
  1630. public subroutine of_mergecells (readonly unsignedinteger row1, readonly unsignedinteger col1, readonly unsignedinteger row2, readonly unsignedinteger col2);Long li_Row
  1631. li_Row=ids_MergeCells.InsertRow(0)
  1632. ids_MergeCells.Object.BeginRow[li_Row]=Row1
  1633. ids_MergeCells.Object.BeginCol[li_Row]=Col1
  1634. ids_MergeCells.Object.EndRow[li_Row]=Row2
  1635. ids_MergeCells.Object.EndCol[li_Row]=Col2
  1636. end subroutine
  1637. public subroutine of_setcellempty (unsignedinteger ai_row, unsignedinteger ai_col);IF ai_Row>UpperBound(inv_Rows) Then
  1638. Return
  1639. END IF
  1640. IF IsNull(inv_Rows[ai_Row]) OR Not IsValid(inv_Rows[ai_Row]) Then
  1641. Return
  1642. END IF
  1643. IF ai_Col >inv_Rows[ai_Row].ii_MaxCol Then
  1644. Return
  1645. END IF
  1646. IF IsNull(inv_Rows[ai_Row].invo_Cells[ai_Col]) OR Not IsValid( inv_Rows[ai_Row].invo_Cells[ai_Col]) Then
  1647. Return
  1648. END IF
  1649. inv_Rows[ai_Row].invo_Cells[ai_Col].ib_Empty=True
  1650. end subroutine
  1651. public function boolean of_isvalidcell (unsignedinteger ai_row, unsignedinteger ai_col, ref n_xls_cell anv_cell);IF ai_Row>UpperBound(inv_Rows) Then
  1652. Return False
  1653. END IF
  1654. IF IsNull(inv_Rows[ai_Row]) OR Not IsValid(inv_Rows[ai_Row]) Then
  1655. Return False
  1656. END IF
  1657. IF ai_Col >inv_Rows[ai_Row].ii_MaxCol Then
  1658. Return False
  1659. END IF
  1660. IF IsNull(inv_Rows[ai_Row].invo_Cells[ai_Col]) OR Not IsValid( inv_Rows[ai_Row].invo_Cells[ai_Col]) Then
  1661. Return False
  1662. END IF
  1663. IF inv_Rows[ai_Row].invo_Cells[ai_Col].ib_Empty THen
  1664. Return False
  1665. END IF
  1666. anv_cell = inv_Rows[ai_Row].invo_Cells[ai_Col]
  1667. Return True
  1668. end function
  1669. public function integer of_store_default_row_height ();integer li_ret = 1
  1670. uint li_record = 549
  1671. uint li_length = 4
  1672. uint li_Height
  1673. blob lb_header
  1674. blob lb_data
  1675. li_Height= of_get_excel_height(id_Default_Row_Height)
  1676. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1677. lb_data = invo_sub.of_pack("v", 1 )+invo_sub.of_pack("v", li_Height)
  1678. of_append_data(lb_header + lb_data)
  1679. return li_ret
  1680. end function
  1681. public function integer of_set_orientation (integer ai_orientation);integer li_ret = 1
  1682. ii_orientation =ai_orientation
  1683. return li_ret
  1684. end function
  1685. protected function integer of_store_mergecells ();
  1686. integer li_ret = 1
  1687. uint li_record = 229
  1688. uint li_length = 10
  1689. blob lb_header
  1690. blob lb_data
  1691. Blob lb_clref
  1692. uint li_clref = 1
  1693. uint li_rwfirst
  1694. uint li_colfirst
  1695. uint li_rwlast
  1696. uint li_collast
  1697. Long li
  1698. IF Not IsValid(ids_MergeCells) Then Return -1
  1699. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1700. lb_clref=invo_sub.of_pack("v", li_clref)
  1701. For li=1 To ids_MergeCells.RowCount()
  1702. li_rwfirst=ids_mergecells.object.beginrow[li] -1
  1703. li_colfirst=ids_mergecells.object.begincol[li] -1
  1704. li_rwlast=ids_mergecells.object.endrow[li] -1
  1705. li_collast=ids_mergecells.object.endcol[li] -1
  1706. lb_data = invo_sub.of_pack("v", li_rwfirst) + invo_sub.of_pack("v", li_rwlast) + invo_sub.of_pack("v", li_colfirst) + invo_sub.of_pack("v", li_collast)
  1707. of_append_data(lb_header + lb_clref + lb_data)
  1708. Next
  1709. Return 1
  1710. end function
  1711. public subroutine of_priorcell_wraptext (unsignedinteger ai_row, unsignedinteger ai_col);IF ai_Row>UpperBound( inv_Rows) OR ai_Row<1 Then
  1712. Return
  1713. END IF
  1714. IF Not IsValid(inv_Rows[ai_Row]) Then
  1715. Return
  1716. END IF
  1717. inv_Rows[ai_Row].OF_PriorCell_wrapText(ai_Col)
  1718. end subroutine
  1719. public function integer of_store_guts ();integer li_ret = 1
  1720. uint li_record = 128 //0x80
  1721. uint li_length = 8
  1722. blob lb_header
  1723. blob lb_data
  1724. uint li_left_row_gutter=0
  1725. uint li_top_col_gutter=0
  1726. uint li_row_level_max=0
  1727. uint li_col_level_max=0
  1728. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  1729. lb_data = invo_sub.of_pack("v", li_left_row_gutter)+invo_sub.of_pack("v", li_top_col_gutter)+invo_sub.of_pack("v", li_row_level_max)+invo_sub.of_pack("v", li_col_level_max)
  1730. of_append_header(lb_header + lb_data)
  1731. return li_ret
  1732. end function
  1733. public subroutine of_set_default_rowheight (double ad_height);id_Default_Row_Height= ad_height
  1734. end subroutine
  1735. public subroutine of_set_print_nocolor (boolean ab_flag);ib_Print_NoColor= ab_flag
  1736. end subroutine
  1737. public subroutine of_set_cellborder ();
  1738. end subroutine
  1739. on n_xls_worksheet.create
  1740. call super::create
  1741. TriggerEvent( this, "constructor" )
  1742. end on
  1743. on n_xls_worksheet.destroy
  1744. TriggerEvent( this, "destructor" )
  1745. call super::destroy
  1746. end on
  1747. event constructor;invo_sub = create n_xls_subroutines
  1748. il_dim_rowmin = il_xls_rowmax + 1
  1749. il_dim_colmin = il_xls_colmax + 1
  1750. invo_selection = create n_xls_selection
  1751. invo_data = create n_xls_data
  1752. invo_header = create n_xls_data
  1753. invo_selection.ii_first_row = 0
  1754. invo_selection.ii_last_row = 0
  1755. invo_selection.ii_first_col = 0
  1756. invo_selection.ii_last_col = 0
  1757. setnull(invo_panes)
  1758. setnull(ii_title_rowmin)
  1759. setnull(ii_title_rowmax)
  1760. setnull(ii_title_colmin)
  1761. setnull(ii_title_colmax)
  1762. setnull(ii_print_rowmin)
  1763. setnull(ii_print_rowmax)
  1764. setnull(ii_print_colmin)
  1765. setnull(ii_print_colmax)
  1766. invo_key_col_sizes = create n_associated_ulong_srv
  1767. invo_key_row_sizes = create n_associated_ulong_srv
  1768. invo_key_col_formats = create n_associated_ulong_srv
  1769. invo_key_row_formats = create n_associated_ulong_srv
  1770. invo_key_col_hiddens = create n_associated_ulong_srv
  1771. invo_key_row_hiddens = create n_associated_ulong_srv
  1772. ids_Mergecells=Create DataStore
  1773. ids_Mergecells.DataObject="d_dw2xls_mergecells"
  1774. end event
  1775. event destructor;destroy(invo_sub)
  1776. destroy invo_selection
  1777. destroy invo_data
  1778. destroy invo_header
  1779. destroy invo_key_col_sizes
  1780. destroy invo_key_row_sizes
  1781. destroy invo_key_col_formats
  1782. destroy invo_key_row_formats
  1783. destroy invo_key_col_hiddens
  1784. destroy invo_key_row_hiddens
  1785. Destroy ids_Mergecells
  1786. end event