n_xls_workbook.sru 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. $PBExportHeader$n_xls_workbook.sru
  2. forward
  3. global type n_xls_workbook from nonvisualobject
  4. end type
  5. end forward
  6. global type n_xls_workbook from nonvisualobject
  7. event type unsignedlong ue_add_string ( string as_value )
  8. event type unsignedlong ue_add_unicode ( blob ab_string )
  9. end type
  10. global n_xls_workbook n_xls_workbook
  11. type variables
  12. PUBLIC STRING is_filename
  13. PUBLIC LONG il_worksheetindex
  14. PUBLIC INTEGER ii_activesheet
  15. PUBLIC INTEGER ii_firstsheet
  16. PUBLIC UINT ii_biff_version = 1536
  17. PUBLIC n_xls_worksheet invo_worksheets[]
  18. PUBLIC n_xls_subroutines invo_sub
  19. Public n_xls_formats invo_Formats
  20. PUBLIC n_xls_data invo_data
  21. PUBLIC n_cst_sst invo_sst
  22. PRIVATE olestorage istg_doc
  23. PRIVATE olestorage invo_olestorage
  24. PUBLIC n_xls_format invo_tmp_format
  25. PUBLIC n_xls_format invo_url_format
  26. PRIVATE BOOLEAN ib_fileclosed = True
  27. PUBLIC BLOB ib_sheetnames[]
  28. PRIVATE STRING is_sheetname = "Sheet"
  29. PUBLIC INTEGER ii_selected
  30. PRIVATE INTEGER ii_palette[4, 56]
  31. PRIVATE UINT iui_codepage = 1252
  32. PROTECTED BLOB iblb_data
  33. PROTECTED ULONG il_datasize
  34. PROTECTED ULONG il_biffsize
  35. PROTECTED UINT iui_limit = 8224
  36. PROTECTED BOOLEAN ib_1904
  37. PROTECTED BOOLEAN ib_WindowProtect
  38. end variables
  39. forward prototypes
  40. public function integer of_create (string as_filename)
  41. public function integer of_close ()
  42. public function integer of_set_custom_color (integer ai_index, integer ai_red, integer ai_green, integer ai_blue)
  43. public function integer of_set_temp_dir (string as_tempdir)
  44. public function integer of_set_codepage (unsignedinteger aui_codepage)
  45. public function integer of_set_palette_xl97 ()
  46. public function long of_get_xf (ref n_xls_format anvo_format)
  47. public function long of_reg_format (ref n_xls_format anvo_format)
  48. public function unsignedinteger of_get_fomratindex (n_xls_format anvo_format)
  49. public function blob of_add_continue (blob ablb_data)
  50. public function integer of_append (blob ablb_data)
  51. public function integer of_append (blob ablb_header, blob ablb_data)
  52. public function integer of_append (blob ablb_header, blob ablb_data, blob ablb_add_data)
  53. public function integer of_calc_sheet_offsets ()
  54. public function integer of_get_externs_size ()
  55. public function integer of_get_names_size ()
  56. public function boolean of_is_number (string as_str)
  57. public function boolean of_is_zero_started_number (string as_str)
  58. public function integer of_store_1904 ()
  59. public function integer of_store_all_fonts ()
  60. public function integer of_store_all_num_formats ()
  61. public function integer of_store_all_styles ()
  62. public function integer of_store_all_xfs ()
  63. public function integer of_store_bof (integer ai_type)
  64. public function integer of_store_boundsheet (blob ab_sheetname, unsignedlong al_offset)
  65. public function integer of_store_codepage ()
  66. public function integer of_store_eof ()
  67. public function integer of_store_externcount (unsignedinteger ai_cxals)
  68. public function integer of_store_externs ()
  69. public function integer of_store_externsheet ()
  70. public function integer of_store_extsst ()
  71. public function integer of_store_name_long (unsignedinteger ai_index, unsignedinteger ai_type, unsignedinteger ai_rowmin, unsignedinteger ai_rowmax, unsignedinteger ai_colmin, unsignedinteger ai_colmax)
  72. public function integer of_store_name_short (unsignedinteger ai_index, unsignedinteger ai_type, unsignedinteger ai_rowmin, unsignedinteger ai_rowmax, unsignedinteger ai_colmin, unsignedinteger ai_colmax)
  73. public function integer of_store_names ()
  74. public function integer of_store_num_format (blob ab_format, unsignedinteger ai_index)
  75. public function integer of_store_ole_file ()
  76. public function integer of_store_palette ()
  77. public function integer of_store_sst (unsignedlong al_offset)
  78. public function integer of_store_style ()
  79. public function integer of_store_supbook ()
  80. public function integer of_store_window1 ()
  81. public function integer of_store_workbook ()
  82. public function n_xls_worksheet of_add_worksheet (blob ab_worksheetname)
  83. public function n_xls_worksheet of_add_worksheet (string as_worksheetname)
  84. public function n_xls_worksheet of_add_worksheet ()
  85. public function n_xls_worksheet of_addworksheet ()
  86. public function n_xls_worksheet of_addworksheet (blob ab_worksheetname)
  87. public function n_xls_worksheet of_addworksheet (string as_worksheetname)
  88. public function integer of_store_mms ()
  89. public function integer of_store_interfacehdr ()
  90. public function integer of_store_interfaceend ()
  91. public function integer of_store_writeaccess ()
  92. public function integer of_store_backup ()
  93. public function integer of_store_dsf ()
  94. public function integer of_store_tabid ()
  95. public function integer of_store_bookbool ()
  96. public function integer of_store_windowprotect ()
  97. public function integer of_store_password ()
  98. public function integer of_store_protect ()
  99. public function integer of_store_system_num_format (unsignedinteger ai_index)
  100. end prototypes
  101. event type unsignedlong ue_add_string(string as_value);return invo_sst.of_add_string(as_value)
  102. end event
  103. event type unsignedlong ue_add_unicode(blob ab_string);return invo_sst.of_add_string(ab_string)
  104. end event
  105. public function integer of_create (string as_filename);integer li_ret = 1
  106. invo_tmp_format = create n_xls_format
  107. of_reg_format(invo_tmp_format)
  108. invo_url_format = create n_xls_format
  109. invo_url_format.of_set_color("blue")
  110. invo_url_format.of_set_underline(1)
  111. of_reg_format(invo_url_format)
  112. if as_filename = "" or isnull(as_filename) then
  113. messagebox("提示", "必须指定文件名称!", Information!, OK! )
  114. li_ret = -1
  115. end if
  116. if li_ret = 1 then
  117. if not ib_fileclosed then
  118. messagebox("提示", "当前文件还没有被保存!", Information!, OK! )
  119. li_ret = -1
  120. end if
  121. end if
  122. if li_ret = 1 then
  123. istg_doc = create olestorage
  124. li_ret = istg_doc.open(as_filename, stgreadwrite!, stgexclusive!)
  125. if li_ret < 0 then
  126. messagebox("提示", "可能其它程序正在打开该文件!~r~n" + "打开文件失败!", Information!, OK! )
  127. istg_doc.Close()
  128. Destroy(istg_doc)
  129. li_ret = -1
  130. else
  131. ib_fileclosed = false
  132. li_ret = 1
  133. end if
  134. end if
  135. if li_ret = 1 then
  136. li_ret = of_set_palette_xl97()
  137. end if
  138. return li_ret
  139. end function
  140. public function integer of_close ();integer li_ret = 1
  141. if not ib_fileclosed then
  142. li_ret = of_store_workbook()
  143. end if
  144. return li_ret
  145. end function
  146. public function integer of_set_custom_color (integer ai_index, integer ai_red, integer ai_green, integer ai_blue);if ai_index < 8 or ai_index > 64 then
  147. messagebox("Error", "Color index " + string(ai_index) + " outside range: 8 <= index <= 64")
  148. return -1
  149. elseif ai_red < 0 or ai_red > 255 or ai_green < 0 or ai_green > 255 or ai_blue < 0 or ai_blue > 255 then
  150. messagebox("Error", "Color component outside range: 0 <= color <= 255")
  151. return -1
  152. else
  153. ai_index = ai_index - 7
  154. ii_palette[1, ai_index] = ai_red
  155. ii_palette[2, ai_index] = ai_green
  156. ii_palette[3, ai_index] = ai_blue
  157. ii_palette[4, ai_index] = 0
  158. return ai_index + 7
  159. end if
  160. end function
  161. public function integer of_set_temp_dir (string as_tempdir);Return 1
  162. end function
  163. public function integer of_set_codepage (unsignedinteger aui_codepage);iui_codepage = aui_codepage
  164. return 1
  165. end function
  166. public function integer of_set_palette_xl97 ();ii_palette[] = { 0, 0, 0, 0, 255, 255, 255, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 255, 0, 255, 255, 0, 0, 255, 0, 255, 0, 0, 255, 255, 0, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128, 0, 128, 128, 0, 0, 128, 0, 128, 0, 0, 128, 128, 0, 192, 192, 192, 0, 128, 128, 128, 0, 153, 153, 255, 0, 153, 51, 102, 0, 255, 255, 204, 0, 204, 255, 255, 0, 102, 0, 102, 0, 255, 128, 128, 0, 0, 102, 204, 0, 204, 204, 255, 0, 0, 0, 128, 0, 255, 0, 255, 0, 255, 255, 0, 0, 0, 255, 255, 0, 128, 0, 128, 0, 128, 0, 0, 0, 0, 128, 128, 0, 0, 0, 255, 0, 0, 204, 255, 0, 204, 255, 255, 0, 204, 255, 204, 0, 255, 255, 153, 0, 153, 204, 255, 0, 255, 153, 204, 0, 204, 153, 255, 0, 255, 204, 153, 0, 51, 102, 255, 0, 51, 204, 204, 0, 153, 204, 0, 0, 255, 204, 0, 0, 255, 153, 0, 0, 255, 102, 0, 0, 102, 102, 153, 0, 150, 150, 150, 0, 0, 51, 102, 0, 51, 153, 102, 0, 0, 51, 0, 0, 51, 51, 0, 0, 153, 51, 0, 0, 153, 51, 102, 0, 51, 51, 153, 0, 51, 51, 51, 0 }
  167. return 1
  168. end function
  169. public function long of_get_xf (ref n_xls_format anvo_format);string ls_key
  170. long li_ret
  171. //if anvo_format.ii_xf_index > 0 then
  172. // return anvo_format.ii_xf_index
  173. //end if
  174. ls_key = anvo_format.of_get_format_key()
  175. li_Ret= invo_Formats.OF_Format_Exist(ls_key)
  176. IF li_Ret<=0 Then
  177. li_Ret=15
  178. END IF
  179. //if invo_xfs.of_key_exists(ls_key) then
  180. // li_ret = invo_xfs.of_get_value(ls_key)
  181. //else
  182. // li_ret = 15
  183. //end if
  184. return li_ret
  185. end function
  186. public function long of_reg_format (ref n_xls_format anvo_format);Return invo_Formats.OF_Add(anvo_format)
  187. end function
  188. public function unsignedinteger of_get_fomratindex (n_xls_format anvo_format);
  189. IF IsNull(anvo_format) OR Not IsValid(anvo_format) Then
  190. Return -1
  191. END IF
  192. Return invo_Formats.OF_Format_Exist(anvo_Format.OF_Get_Format_Key())
  193. end function
  194. public function blob of_add_continue (blob ablb_data);uint lui_record = 60
  195. blob lblb_header
  196. blob lblb_temp
  197. long ll_len
  198. lblb_temp = blobmid(ablb_data, 1, iui_limit)
  199. ablb_data = blobmid(ablb_data, iui_limit + 1, len(ablb_data) - iui_limit)
  200. blobedit(lblb_temp, 3, invo_sub.of_pack("v", iui_limit - 4))
  201. do While len(ablb_data) > iui_limit
  202. lblb_header = invo_sub.of_pack("v", lui_record) + invo_sub.of_pack("v", iui_limit)
  203. lblb_temp = lblb_temp + lblb_header
  204. lblb_temp = lblb_temp + blobmid(ablb_data, 1, iui_limit)
  205. ablb_data = blobmid(ablb_data, iui_limit + 1, len(ablb_data) - iui_limit)
  206. loop
  207. lblb_header = invo_sub.of_pack("v", lui_record) + invo_sub.of_pack("v", len(ablb_data))
  208. lblb_temp = lblb_temp + lblb_header
  209. lblb_temp = lblb_temp + ablb_data
  210. return lblb_temp
  211. end function
  212. public function integer of_append (blob ablb_data);integer li_ret = 1
  213. if len(ablb_data) > iui_limit then
  214. ablb_data = of_add_continue(ablb_data)
  215. end if
  216. il_datasize += len(ablb_data)
  217. invo_data.of_append(ablb_data)
  218. return li_ret
  219. end function
  220. public function integer of_append (blob ablb_header, blob ablb_data);return of_append(ablb_header + ablb_data)
  221. end function
  222. public function integer of_append (blob ablb_header, blob ablb_data, blob ablb_add_data);return of_append(ablb_header + ablb_data + ablb_add_data)
  223. end function
  224. public function integer of_calc_sheet_offsets ();integer li_ret = 1
  225. integer li_boundsheetheader = 12
  226. integer li_eof = 4
  227. ulong ll_offset
  228. long ll_i
  229. n_xls_worksheet lnvo_sheet
  230. ll_offset = il_datasize
  231. for ll_i = 1 to il_worksheetindex
  232. lnvo_sheet = invo_worksheets[ll_i]
  233. ll_offset += li_boundsheetheader + len(lnvo_sheet.ib_worksheetname)
  234. next
  235. ll_offset += of_get_externs_size()
  236. ll_offset += of_get_names_size()
  237. ll_offset += li_eof
  238. for ll_i = 1 to il_worksheetindex
  239. lnvo_sheet = invo_worksheets[ll_i]
  240. lnvo_sheet.il_offset = ll_offset
  241. ll_offset += lnvo_sheet.il_datasize
  242. next
  243. il_biffsize = ll_offset
  244. return li_ret
  245. end function
  246. public function integer of_get_externs_size ();integer li_cnt
  247. li_cnt=upperbound(ib_sheetnames)
  248. return 8 + 6 + 6 * li_cnt
  249. end function
  250. public function integer of_get_names_size ();integer li_ret
  251. long ll_i
  252. n_xls_worksheet lnvo_sheet
  253. for ll_i = 1 to il_worksheetindex
  254. lnvo_sheet = invo_worksheets[ll_i]
  255. if not isnull(lnvo_sheet.ii_print_rowmin) then
  256. li_ret = li_ret + 31
  257. end if
  258. next
  259. for ll_i = 1 to il_worksheetindex
  260. lnvo_sheet = invo_worksheets[ll_i]
  261. if not isnull(lnvo_sheet.ii_title_rowmin) and not isnull(lnvo_sheet.ii_title_colmin) then
  262. li_ret = li_ret + 46
  263. elseif not isnull(lnvo_sheet.ii_title_rowmin) then
  264. li_ret = li_ret + 31
  265. elseif not isnull(lnvo_sheet.ii_title_colmin) then
  266. li_ret = li_ret + 31
  267. end if
  268. next
  269. return li_ret
  270. end function
  271. public function boolean of_is_number (string as_str);integer li_i
  272. integer li_cnt
  273. string ls_ch
  274. as_str = trim(as_str)
  275. li_cnt = len(as_str)
  276. if li_cnt < 1 then
  277. return false
  278. end if
  279. for li_i = 1 to li_cnt
  280. ls_ch = mid(as_str, li_i, 1)
  281. choose case ls_ch
  282. case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  283. continue
  284. case else
  285. return false
  286. end choose
  287. next
  288. return true
  289. end function
  290. public function boolean of_is_zero_started_number (string as_str);integer li_i
  291. integer li_cnt
  292. string ls_ch
  293. as_str = trim(as_str)
  294. if right(as_str, 1) = "0" then
  295. li_cnt = len(as_str)
  296. if li_cnt < 2 then
  297. return false
  298. end if
  299. for li_i = 2 to li_cnt
  300. ls_ch = mid(as_str, li_i, 1)
  301. choose case ls_ch
  302. case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  303. continue
  304. case else
  305. return false
  306. end choose
  307. next
  308. return true
  309. else
  310. return false
  311. end if
  312. end function
  313. public function integer of_store_1904 ();uint li_record = 34
  314. uint li_length = 2
  315. integer li_ret
  316. blob lblb_header
  317. blob lblb_data
  318. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  319. if ib_1904 then
  320. lblb_data = invo_sub.of_pack("v", 1)
  321. else
  322. lblb_data = invo_sub.of_pack("v", 0)
  323. end if
  324. li_ret = of_append(lblb_header, lblb_data)
  325. return li_ret
  326. end function
  327. public function integer of_store_all_fonts ();blob lb_font
  328. string ls_key
  329. string ls_font_keys[]
  330. long ll_keys_cnt
  331. long ll_format_cnt
  332. long ll_i
  333. long ll_j
  334. long ll_key
  335. integer li_ret = 1
  336. lb_font = invo_tmp_format.of_get_font()
  337. for ll_i = 1 to 5
  338. of_append(lb_font)
  339. next
  340. ll_j=upperbound(invo_formats.iblob_font)
  341. for ll_i=1 to ll_j
  342. of_append(invo_formats.iblob_font[ll_i])
  343. next
  344. return li_ret
  345. end function
  346. public function integer of_store_all_num_formats ();Long li
  347. Long li_COunt
  348. blob lb_data
  349. li_COunt=UpperBound(invo_formats.is_num_format)
  350. for li = 1 to li_COunt
  351. lb_data= invo_sub.to_unicode(invo_formats.is_num_format[li])
  352. of_store_num_format(lb_data, li + 164 -1 )
  353. next
  354. return 1
  355. end function
  356. public function integer of_store_all_styles ();integer li_ret
  357. li_ret = of_store_style()
  358. return li_ret
  359. end function
  360. public function integer of_store_all_xfs ();blob lb_xf
  361. long li,li_count
  362. lb_xf = invo_tmp_format.of_get_xf("style")
  363. for li = 1 to 15
  364. of_append(lb_xf)
  365. next
  366. li_count=upperbound( invo_formats.iblob_xfs)
  367. for li=1 to li_count
  368. of_append(invo_formats.iblob_xfs[li])
  369. next
  370. return 1
  371. end function
  372. public function integer of_store_bof (integer ai_type);uint li_record = 2057
  373. uint li_len = 16
  374. uint li_build = 6319
  375. uint li_year = 1997
  376. ulong ll_history_flag = 16449
  377. ulong ll_lowest_version = 262
  378. blob lblb_header
  379. blob lblb_data
  380. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_len)
  381. lblb_data = invo_sub.of_pack("v", ii_biff_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)
  382. of_append(lblb_header + lblb_data)
  383. return 1
  384. end function
  385. public function integer of_store_boundsheet (blob ab_sheetname, unsignedlong al_offset);integer li_ret = 1
  386. uint li_record = 133
  387. uint li_length
  388. uint li_grbit
  389. uint li_cch
  390. blob lb_header
  391. blob lb_data
  392. li_cch = len(ab_sheetname) / 2
  393. li_length = 8 + li_cch * 2
  394. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  395. lb_data = invo_sub.of_pack("V", al_offset) + invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("C", li_cch) + invo_sub.of_pack("C", 1) + ab_sheetname
  396. of_append(lb_header, lb_data)
  397. return li_ret
  398. end function
  399. public function integer of_store_codepage ();uint li_record = 66
  400. uint li_length = 2
  401. blob lblb_header
  402. blob lblb_data
  403. integer li_ret
  404. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  405. lblb_data = invo_sub.of_pack("v", 1200)
  406. li_ret = of_append(lblb_header, lblb_data)
  407. return li_ret
  408. end function
  409. public function integer of_store_eof ();integer li_ret = 1
  410. uint li_record = 10
  411. uint li_length
  412. blob lb_header
  413. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  414. of_append(lb_header)
  415. return li_ret
  416. end function
  417. public function integer of_store_externcount (unsignedinteger ai_cxals);integer li_ret = 1
  418. uint li_record = 22
  419. uint li_length = 2
  420. blob lb_header
  421. blob lb_data
  422. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  423. lb_data = invo_sub.of_pack("v", ai_cxals)
  424. of_append(lb_header, lb_data)
  425. return li_ret
  426. end function
  427. public function integer of_store_externs ();of_store_supbook()
  428. of_store_externsheet()
  429. return 1
  430. end function
  431. public function integer of_store_externsheet ();integer li_ret = 1
  432. uint li_record = 23
  433. uint li_length
  434. blob lb_header
  435. blob lb_data
  436. integer li_i
  437. integer li_cnt
  438. li_cnt = upperbound(ib_sheetnames)
  439. li_length = 2 + 6 * li_cnt
  440. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  441. lb_data = invo_sub.of_pack("v", li_cnt)
  442. for li_i = li_cnt - 1 to 0 step -1 //65535
  443. lb_data = lb_data + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", li_i) + invo_sub.of_pack("v", li_i)
  444. next
  445. of_append(lb_header + lb_data)
  446. return li_ret
  447. end function
  448. public function integer of_store_extsst ();integer li_ret = 1
  449. blob lblb_data
  450. lblb_data = invo_sst.of_get_extsst()
  451. il_datasize += len(lblb_data)
  452. invo_data.of_append(lblb_data)
  453. return li_ret
  454. end function
  455. public function integer of_store_name_long (unsignedinteger ai_index, unsignedinteger ai_type, unsignedinteger ai_rowmin, unsignedinteger ai_rowmax, unsignedinteger ai_colmin, unsignedinteger ai_colmax);integer li_ret = 1
  456. uint li_record = 24
  457. uint li_length = 42
  458. uint li_grbit = 32
  459. integer li_chkey
  460. integer li_cch = 1
  461. uint li_cce = 26
  462. uint li_ixals
  463. uint li_itab
  464. integer li_cchcustmenu
  465. integer li_cchdescription
  466. integer li_cchhelptopic
  467. integer li_cchstatustext
  468. integer li_rgch
  469. integer li_unknown03 = 41
  470. uint li_unknown04 = 23
  471. integer li_unknown05 = 59
  472. blob lb_header
  473. blob lb_data
  474. uint li_ext_ref
  475. li_ixals = ai_index + 1
  476. li_itab = li_ixals
  477. li_rgch = ai_type
  478. li_ext_ref = upperbound(ib_sheetnames) - ai_index - 1
  479. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  480. lb_data = invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("C", li_chkey) + invo_sub.of_pack("C", li_cch) + invo_sub.of_pack("v", li_cce) + invo_sub.of_pack("v", ai_index) + invo_sub.of_pack("v", li_itab) + invo_sub.of_pack("C", li_cchcustmenu) + invo_sub.of_pack("C", li_cchdescription) + invo_sub.of_pack("C", li_cchhelptopic) + invo_sub.of_pack("C", li_cchstatustext) + invo_sub.of_pack("C", 0) + invo_sub.of_pack("C", li_rgch) + invo_sub.of_pack("C", li_unknown03) + invo_sub.of_pack("v", li_unknown04) + invo_sub.of_pack("C", li_unknown05) + invo_sub.of_pack("v", li_ext_ref) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 65535) + invo_sub.of_pack("v", ai_colmin) + invo_sub.of_pack("v", ai_colmax) + invo_sub.of_pack("C", li_unknown05) + invo_sub.of_pack("v", li_ext_ref) + invo_sub.of_pack("v", ai_rowmin) + invo_sub.of_pack("v", ai_rowmax) + invo_sub.of_pack("v", 0) + invo_sub.of_pack("v", 255) + invo_sub.of_pack("C", 16)
  481. of_append(lb_header, lb_data)
  482. return li_ret
  483. end function
  484. public function integer of_store_name_short (unsignedinteger ai_index, unsignedinteger ai_type, unsignedinteger ai_rowmin, unsignedinteger ai_rowmax, unsignedinteger ai_colmin, unsignedinteger ai_colmax);integer li_ret = 1
  485. uint li_record = 24
  486. uint li_length = 27
  487. uint li_grbit = 32
  488. integer li_chkey
  489. integer li_cch = 1
  490. uint li_cce = 11
  491. uint li_ixals
  492. uint li_itab
  493. integer li_cchcustmenu
  494. integer li_cchdescription
  495. integer li_cchhelptopic
  496. integer li_cchstatustext
  497. integer li_rgch
  498. integer li_unknown03 = 59
  499. uint li_unknown04
  500. blob lb_header
  501. blob lb_data
  502. li_ixals = ai_index + 1
  503. li_itab = li_ixals
  504. li_rgch = ai_type
  505. li_unknown04 = upperbound(ib_sheetnames) - ai_index - 1
  506. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  507. lb_data = invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("C", li_chkey) + invo_sub.of_pack("C", li_cch) + invo_sub.of_pack("v", li_cce) + invo_sub.of_pack("v", ai_index) + invo_sub.of_pack("v", li_itab) + invo_sub.of_pack("C", li_cchcustmenu) + invo_sub.of_pack("C", li_cchdescription) + invo_sub.of_pack("C", li_cchhelptopic) + invo_sub.of_pack("C", li_cchstatustext) + invo_sub.of_pack("C", 0) + invo_sub.of_pack("C", li_rgch) + invo_sub.of_pack("C", li_unknown03) + invo_sub.of_pack("v", li_unknown04) + invo_sub.of_pack("v", ai_rowmin) + invo_sub.of_pack("v", ai_rowmax) + invo_sub.of_pack("v", ai_colmin) + invo_sub.of_pack("v", ai_colmax)
  508. of_append(lb_header, lb_data)
  509. return li_ret
  510. end function
  511. public function integer of_store_names ();integer li_ret = 1
  512. long ll_i
  513. n_xls_worksheet lnvo_sheet
  514. for ll_i = 1 to il_worksheetindex
  515. lnvo_sheet = invo_worksheets[ll_i]
  516. if not isnull(lnvo_sheet.ii_print_rowmin) then
  517. of_store_name_short(ll_i - 1, 6, lnvo_sheet.ii_print_rowmin, lnvo_sheet.ii_print_rowmax, lnvo_sheet.ii_print_colmin, lnvo_sheet.ii_print_colmax)
  518. end if
  519. next
  520. for ll_i = 1 to il_worksheetindex
  521. lnvo_sheet = invo_worksheets[ll_i]
  522. if not isnull(lnvo_sheet.ii_title_rowmin) and not isnull(lnvo_sheet.ii_title_colmin) then
  523. of_store_name_long(ll_i - 1, 7, lnvo_sheet.ii_title_rowmin, lnvo_sheet.ii_title_rowmax, lnvo_sheet.ii_title_colmin, lnvo_sheet.ii_title_colmax)
  524. elseif not isnull(lnvo_sheet.ii_title_rowmin) then
  525. of_store_name_short(ll_i - 1, 7, lnvo_sheet.ii_title_rowmin, lnvo_sheet.ii_title_rowmax, 0, 255)
  526. elseif not isnull(lnvo_sheet.ii_title_colmin) then
  527. of_store_name_short(ll_i - 1, 7, 0, 65535, lnvo_sheet.ii_title_colmin, lnvo_sheet.ii_title_colmax)
  528. end if
  529. next
  530. return li_ret
  531. end function
  532. public function integer of_store_num_format (blob ab_format, unsignedinteger ai_index);integer li_ret = 1
  533. uint li_record = 1054
  534. uint li_length
  535. uint li_len_format
  536. blob lb_header
  537. blob lb_data
  538. integer li_grbit = 1
  539. integer li_cch
  540. li_cch = len(ab_format) / 2
  541. li_length = 5 + li_cch * 2
  542. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  543. lb_data = invo_sub.of_pack("v", ai_index) + invo_sub.of_pack("v", li_cch) + invo_sub.of_pack("C", li_grbit) + ab_format
  544. of_append(lb_header, lb_data)
  545. return li_ret
  546. end function
  547. public function integer of_store_ole_file ();integer li_ret = 1
  548. integer li_i
  549. olestream lstr_book
  550. n_xls_worksheet lnvo_sheet
  551. lstr_book = create olestream
  552. li_ret = lstr_book.open(istg_doc, "Workbook", stgwrite!)
  553. if li_ret < 0 then
  554. li_ret = -1
  555. else
  556. li_ret = 1
  557. end if
  558. if li_ret = 1 then
  559. invo_data.of_write(lstr_book)
  560. end if
  561. if li_ret = 1 then
  562. for li_i = 1 to il_worksheetindex
  563. lnvo_sheet = invo_worksheets[li_i]
  564. lnvo_sheet.of_write_data(lstr_book)
  565. next
  566. end if
  567. if li_ret = 1 then
  568. lstr_book.close()
  569. istg_doc.close()
  570. end if
  571. return li_ret
  572. end function
  573. public function integer of_store_palette ();integer li_ret = 1
  574. uint li_record = 146
  575. uint li_length
  576. uint li_ccv
  577. uint li_i
  578. blob lb_header
  579. blob lb_data
  580. blob lb_data_item
  581. li_ccv = 56
  582. li_length = 2 + 4 * li_ccv
  583. for li_i = 1 to li_ccv
  584. lb_data_item = invo_sub.of_pack("C", ii_palette[1, li_i]) + invo_sub.of_pack("C", ii_palette[2, li_i]) + invo_sub.of_pack("C", ii_palette[3, li_i]) + invo_sub.of_pack("C", ii_palette[4, li_i])
  585. if li_i = 1 then
  586. lb_data = lb_data_item
  587. else
  588. lb_data = lb_data + lb_data_item
  589. end if
  590. next
  591. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length) + invo_sub.of_pack("v", li_ccv)
  592. of_append(lb_header, lb_data)
  593. return li_ret
  594. end function
  595. public function integer of_store_sst (unsignedlong al_offset);integer li_ret = 1
  596. blob lblb_data
  597. lblb_data = invo_sst.of_get_sst(al_offset)
  598. il_datasize += len(lblb_data)
  599. invo_data.of_append(lblb_data)
  600. return li_ret
  601. end function
  602. public function integer of_store_style ();integer li_ret
  603. uint li_record = 659
  604. uint li_length = 4
  605. uint li_ixfe = 32768
  606. integer li_builtin
  607. integer li_ilevel = 255
  608. blob lb_header
  609. blob lb_data
  610. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  611. lb_data = invo_sub.of_pack("v", li_ixfe) + invo_sub.of_pack("C", li_builtin) + invo_sub.of_pack("C", li_ilevel)
  612. of_append(lb_header, lb_data)
  613. return li_ret
  614. end function
  615. public function integer of_store_supbook ();uint li_record = 430
  616. uint li_length = 4
  617. blob lblb_header
  618. blob lblb_data
  619. integer li_ret
  620. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  621. lblb_data = invo_sub.of_pack("v", upperbound(ib_sheetnames)) + invo_sub.of_pack("v", 1025)
  622. li_ret = of_append(lblb_header, lblb_data)
  623. return li_ret
  624. end function
  625. public function integer of_store_window1 ();integer li_ret = 1
  626. uint li_record = 61
  627. uint li_length = 18
  628. uint li_xwn
  629. uint li_ywn
  630. uint li_dxwn = 9660
  631. uint li_dywn = 5490
  632. uint li_grbit = 56
  633. uint li_wtabratio = 600
  634. blob lblb_header
  635. blob lblb_data
  636. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  637. lblb_data = invo_sub.of_pack("v", li_xwn) + invo_sub.of_pack("v", li_ywn) + invo_sub.of_pack("v", li_dxwn) + invo_sub.of_pack("v", li_dywn) + invo_sub.of_pack("v", li_grbit) + invo_sub.of_pack("v", ii_activesheet) + invo_sub.of_pack("v", ii_firstsheet) + invo_sub.of_pack("v", ii_selected) + invo_sub.of_pack("v", li_wtabratio)
  638. of_append(lblb_header, lblb_data)
  639. return li_ret
  640. end function
  641. public function integer of_store_workbook ();long ll_i
  642. n_xls_worksheet lnvo_sheet
  643. if il_worksheetindex = 0 then
  644. of_add_worksheet()
  645. end if
  646. if ii_activesheet = 0 then
  647. lnvo_sheet = invo_worksheets[1]
  648. lnvo_sheet.ib_selected = true
  649. end if
  650. for ll_i = 1 to il_worksheetindex
  651. lnvo_sheet = invo_worksheets[ll_i]
  652. if lnvo_sheet.ib_selected then
  653. ii_selected ++
  654. end if
  655. lnvo_sheet.of_close()
  656. next
  657. of_store_bof(5)
  658. //新增的函数
  659. //of_store_InterfaceHdr()
  660. //of_store_MMS()
  661. //of_store_interfaceEnd()
  662. //of_store_WriteAccess()
  663. //records.add( retval.createCodepage() );
  664. //records.add( retval.createDSF() );
  665. //records.add( retval.createTabId() );
  666. //retval.records.setTabpos( records.size() - 1 );
  667. //records.add( retval.createFnGroupCount() );
  668. //records.add( retval.createWindowProtect() );
  669. //records.add( retval.createProtect() );
  670. //retval.records.setProtpos( records.size() - 1 );
  671. //records.add( retval.createPassword() );
  672. //records.add( retval.createProtectionRev4() );
  673. //records.add( retval.createPasswordRev4() );
  674. //records.add( retval.createWindowOne() );
  675. //records.add( retval.createBackup() );
  676. //retval.records.setBackuppos( records.size() - 1 );
  677. //records.add( retval.createHideObj() );
  678. //records.add( retval.createDateWindow1904() );
  679. //records.add( retval.createPrecision() );
  680. //records.add( retval.createRefreshAll() );
  681. //records.add( retval.createBookBool() );
  682. //records.add( retval.createFont() );
  683. //records.add( retval.createFont() );
  684. //records.add( retval.createFont() );
  685. //records.add( retval.createFont() );
  686. of_store_codepage()
  687. ////NEW
  688. //of_store_dsf()
  689. //of_store_tabID()
  690. //of_store_WindowProtect()
  691. //of_store_password()
  692. //of_store_protect()
  693. of_store_window1()
  694. //of_store_backup() //NEW
  695. of_store_1904()
  696. //of_Store_BookBool() //NEW
  697. of_store_all_fonts()
  698. //for ll_i=1 to 8
  699. // of_store_system_num_format(ll_i)
  700. //Next
  701. of_store_all_num_formats() //保存自定义格式
  702. of_store_all_xfs()
  703. of_store_all_styles()
  704. of_store_palette()
  705. of_store_sst(il_datasize)
  706. of_store_extsst()
  707. of_calc_sheet_offsets()
  708. for ll_i = 1 to il_worksheetindex
  709. lnvo_sheet = invo_worksheets[ll_i]
  710. of_store_boundsheet(lnvo_sheet.ib_worksheetname, lnvo_sheet.il_offset)
  711. next
  712. of_store_externs()
  713. of_store_names()
  714. of_store_eof()
  715. return of_store_ole_file()
  716. end function
  717. public function n_xls_worksheet of_add_worksheet (blob ab_worksheetname);integer li_ret = 1
  718. integer li_i
  719. integer li_len
  720. string ls_name
  721. n_xls_worksheet lnvo_cursheet
  722. n_xls_worksheet lnvo_worksheet
  723. ls_name = invo_sub.to_ansi(ab_worksheetname, 0, "_")
  724. do
  725. li_len = len(ab_worksheetname) / 2
  726. if li_len > 31 then
  727. messagebox("Error", "Length of Worksheet name must be less then 31 symbols", stopsign!)
  728. li_ret = -1
  729. exit
  730. end if
  731. if match(ls_name, "[:*?/\]") then
  732. messagebox("Error", "Invalid worksheet name", stopsign!)
  733. li_ret = -1
  734. exit
  735. end if
  736. if trim(ls_name) = "" then
  737. ab_worksheetname = invo_sub.to_unicode(is_sheetname + string(il_worksheetindex + 1))
  738. ls_name = invo_sub.to_ansi(ab_worksheetname, 0, "_")
  739. end if
  740. for li_i = 1 to il_worksheetindex
  741. lnvo_cursheet = invo_worksheets[li_i]
  742. if lnvo_cursheet.ib_worksheetname = ab_worksheetname then
  743. messagebox("Error", "Duplicate worksheet name", stopsign!)
  744. li_ret = -1
  745. exit
  746. end if
  747. next
  748. if li_ret <> 1 then
  749. exit
  750. end if
  751. lnvo_worksheet = create n_xls_worksheet
  752. lnvo_worksheet.invo_url_format = invo_url_format
  753. lnvo_worksheet.invo_workbook = this
  754. lnvo_worksheet.ib_worksheetname = ab_worksheetname
  755. lnvo_worksheet.is_worksheetname = ls_name
  756. il_worksheetindex ++
  757. lnvo_worksheet.ii_index = il_worksheetindex
  758. ib_sheetnames[il_worksheetindex] = lnvo_worksheet.ib_worksheetname
  759. invo_worksheets[il_worksheetindex] = lnvo_worksheet
  760. loop Until true
  761. if li_ret <> 1 then
  762. if not isnull(lnvo_worksheet) then
  763. if isvalid(lnvo_worksheet) then
  764. destroy(lnvo_worksheet)
  765. setnull(lnvo_worksheet)
  766. end if
  767. end if
  768. end if
  769. return lnvo_worksheet
  770. end function
  771. public function n_xls_worksheet of_add_worksheet (string as_worksheetname);return of_add_worksheet(invo_sub.to_unicode(as_worksheetname))
  772. end function
  773. public function n_xls_worksheet of_add_worksheet ();return of_add_worksheet("")
  774. end function
  775. public function n_xls_worksheet of_addworksheet ();return of_add_worksheet()
  776. end function
  777. public function n_xls_worksheet of_addworksheet (blob ab_worksheetname);return of_add_worksheet(ab_worksheetname)
  778. end function
  779. public function n_xls_worksheet of_addworksheet (string as_worksheetname);return of_add_worksheet(as_worksheetname)
  780. end function
  781. public function integer of_store_mms ();uint li_record = 193 //0xC1
  782. uint li_length = 2
  783. int li_addMenuCount=0
  784. int li_delMenuCount = 0
  785. integer li_ret
  786. blob lblb_header
  787. blob lblb_data
  788. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  789. lblb_data = invo_sub.of_pack("c", li_addMenuCount) + invo_sub.of_pack("c", li_delMenuCount)
  790. li_ret = of_append(lblb_header,lblb_data)
  791. return li_ret
  792. end function
  793. public function integer of_store_interfacehdr ();integer li_ret
  794. uint li_record = 225 //0xE1
  795. uint li_length = 2
  796. uint li_codepage = 1252 // 0x4b0
  797. blob lb_header
  798. blob lb_data
  799. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  800. lb_data = invo_sub.of_pack("v", li_codepage)
  801. of_append(lb_header, lb_data)
  802. return li_ret
  803. end function
  804. public function integer of_store_interfaceend ();uint li_record = 226 // 0x e2
  805. integer li_ret
  806. blob lblb_header
  807. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", 0)
  808. li_ret = of_append(lblb_header)
  809. return li_ret
  810. end function
  811. public function integer of_store_writeaccess ();uint li_record = 92 //0x5c
  812. uint li_length =112
  813. String ls_username ='黄国酬'
  814. integer li_ret
  815. blob lblb_header
  816. blob lblb_data
  817. blob lb_username
  818. int li ,li_len
  819. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  820. ls_username = ls_username +Space(109 - Len(ls_username ))
  821. lb_username= invo_sub.to_unicode(ls_username,1252)
  822. li_len= len(lb_username)/2
  823. for li=1 to li_len
  824. lblb_data+= invo_sub.of_pack('c',asc(char(blobMid(lb_username , ( li -1 ) * 2+1, 2))))
  825. next
  826. lblb_data = invo_sub.of_pack('v',3)+invo_sub.of_pack('C',0)+lblb_data
  827. of_append( lblb_header,lblb_data)
  828. return li_ret
  829. end function
  830. public function integer of_store_backup ();uint li_record = 64 //0x40
  831. uint li_length = 2
  832. uint li_backup = 0
  833. integer li_ret
  834. blob lblb_header
  835. blob lblb_data
  836. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  837. lblb_data = invo_sub.of_pack("v", li_backup)
  838. li_ret = of_append(lblb_header, lblb_data)
  839. return li_ret
  840. end function
  841. public function integer of_store_dsf ();uint li_record = 353 // 0x161
  842. uint li_length = 2
  843. uint li_dsf=0
  844. integer li_ret
  845. blob lblb_header
  846. blob lblb_data
  847. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  848. lblb_data = invo_sub.of_pack("v", li_dsf)
  849. li_ret = of_append(lblb_header, lblb_data)
  850. return li_ret
  851. end function
  852. public function integer of_store_tabid ();uint li_record = 317 //0X13d
  853. uint li_length = 0
  854. uint li_tabids = 0
  855. integer li_ret
  856. blob lblb_header
  857. blob lblb_data
  858. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  859. //lblb_data = invo_sub.of_pack("v", li_tabids)
  860. li_ret = of_append(lblb_header, lblb_data)
  861. return li_ret
  862. end function
  863. public function integer of_store_bookbool ();uint li_record = 218 //0xDA
  864. uint li_length = 2
  865. uint li_save_link_values = 0
  866. integer li_ret
  867. blob lblb_header
  868. blob lblb_data
  869. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  870. lblb_data = invo_sub.of_pack("v", li_save_link_values)
  871. li_ret = of_append(lblb_header, lblb_data)
  872. return li_ret
  873. end function
  874. public function integer of_store_windowprotect ();//uint li_record = 25 //0x19
  875. //uint li_length = 2
  876. //integer li_ret
  877. //blob lblb_header
  878. //blob lblb_data
  879. //
  880. //lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  881. //
  882. //if ib_WindowProtect then
  883. // lblb_data = invo_sub.of_pack("v", 1)
  884. //else
  885. // lblb_data = invo_sub.of_pack("v", 0)
  886. //end if
  887. //
  888. //li_ret = of_append(lblb_header, lblb_data)
  889. //return li_ret
  890. Return 1
  891. end function
  892. public function integer of_store_password ();uint li_record = 19 //0x13
  893. uint li_length = 2
  894. uint li_password
  895. integer li_ret
  896. blob lblb_header
  897. blob lblb_data
  898. lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  899. lblb_data = invo_sub.of_pack("v", li_password)
  900. li_ret = of_append(lblb_header, lblb_data)
  901. return li_ret
  902. end function
  903. public function integer of_store_protect ();//uint li_record = 18 //0x12
  904. //uint li_length = 2
  905. //uint li_protect
  906. //integer li_ret
  907. //blob lblb_header
  908. //blob lblb_data
  909. //
  910. //lblb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  911. //lblb_data = invo_sub.of_pack("v", li_protect)
  912. //li_ret = of_append(lblb_header, lblb_data)
  913. //
  914. //return li_ret
  915. Return 1
  916. end function
  917. public function integer of_store_system_num_format (unsignedinteger ai_index);integer li_ret = 1
  918. uint li_record = 1054
  919. uint li_length
  920. uint li_len_format
  921. blob lb_header
  922. blob lb_data
  923. integer li_grbit = 1
  924. integer li_cch
  925. String ls_Format
  926. blob lb_Format
  927. Choose Case ai_Index
  928. Case 1
  929. ls_Format= "$#,##0_);\($#,##0\)"
  930. ai_Index = 5
  931. Case 2
  932. ls_Format = "$#,##0_);[Red]\($#,##0\)"
  933. ai_Index=6
  934. Case 3
  935. ls_Format = "$#,##0.00_);\($#,##0.00\)"
  936. ai_Index=7
  937. Case 4
  938. ls_Format = "$#,##0.00_);[Red]\($#,##0.00\)"
  939. ai_Index=8
  940. Case 5
  941. ls_Format = "_($* #,##0_);_($* \(#,##0\);_($* -_);_(@_)"
  942. ai_Index=40 //0x2a
  943. Case 6
  944. ls_Format = "_(* #,##0_);_(* \(#,##0\);_(* -_);_(@_)"
  945. ai_Index=41
  946. Case 7
  947. ls_Format = "_($* #,##0.00_);_($* \(#,##0.00\);_($* -??_);_(@_)"
  948. ai_Index=58
  949. Case 8
  950. ls_Format = "_(* #,##0.00_);_(* \(#,##0.00\);_(* -??_);_(@_)"
  951. ai_Index=31
  952. END CHOOSE
  953. lb_format = invo_sub.to_unicode(ls_format)
  954. li_cch = len(ls_format)
  955. li_length = 5 + li_cch * 2
  956. lb_header = invo_sub.of_pack("v", li_record) + invo_sub.of_pack("v", li_length)
  957. lb_data = invo_sub.of_pack("v", ai_index) + invo_sub.of_pack("v", li_cch) + invo_sub.of_pack("C", li_grbit) + lb_Format
  958. of_append(lb_header, lb_data)
  959. return li_ret
  960. end function
  961. on n_xls_workbook.create
  962. call super::create
  963. TriggerEvent( this, "constructor" )
  964. end on
  965. on n_xls_workbook.destroy
  966. TriggerEvent( this, "destructor" )
  967. call super::destroy
  968. end on
  969. event constructor;invo_sub = create n_xls_subroutines
  970. //invo_xfs = create n_cst_hash_long
  971. invo_data = create n_xls_data
  972. invo_sst = create n_cst_sst
  973. invo_Formats=create n_xls_formats
  974. end event
  975. event destructor;int li
  976. destroy(invo_sub)
  977. destroy(invo_sst)
  978. destroy invo_sub
  979. destroy invo_Formats
  980. destroy invo_data
  981. destroy istg_doc
  982. destroy invo_olestorage
  983. destroy invo_tmp_format
  984. destroy invo_url_format
  985. For li=1 To UpperBound( invo_worksheets)
  986. Destroy invo_worksheets[li]
  987. Next
  988. end event