n_xls_cell.sru 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. $PBExportHeader$n_xls_cell.sru
  2. forward
  3. global type n_xls_cell from nonvisualobject
  4. end type
  5. end forward
  6. global type n_xls_cell from nonvisualobject
  7. end type
  8. global n_xls_cell n_xls_cell
  9. type variables
  10. PUBLIC BOOLEAN ib_Empty =True
  11. PUBLIC UInt Row
  12. PUBLIC Uint Col
  13. PUBLIC UINT EndRow
  14. public uint EndCol
  15. Public uint ii_xf
  16. PUBLIC String is_Value
  17. PUBLIC String is_CellType ='S'
  18. pUBLIC n_xls_Format invo_Format
  19. PUBLIC n_xls_WorkSheet invo_WorkSheet
  20. end variables
  21. forward prototypes
  22. public function integer of_getdata (ref blob ab_data)
  23. public function blob of_getformatonly (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col)
  24. end prototypes
  25. public function integer of_getdata (ref blob ab_data);integer li_ret = 1
  26. ulong ll_sst_index
  27. double ld_val
  28. DateTime ldt_dateTime
  29. time lt_time
  30. integer li_hour
  31. integer li_minute
  32. integer li_second
  33. Integer li_Pos
  34. Blob lb_unicode_value
  35. IF ii_xf<=0 Then
  36. ii_xf =invo_WorkSheet.invo_WorkBook.OF_Reg_Format(invo_Format) //of_xf(ai_row, ai_col, lnvo_format)
  37. ii_xf=ii_xf +14 //加14 可能是因为在workbook的of_store_xfs中,有15个style类型格式
  38. //具体原因需要进一步分析
  39. END IF
  40. IF is_Value="" OR IsNull(is_Value) Then
  41. ab_data = invo_WorkSheet.invo_sub.of_pack("v", row -1) + invo_WorkSheet.invo_sub.of_pack("v", col -1 ) + invo_WorkSheet.invo_sub.of_pack("v", ii_xf)
  42. Return li_ret
  43. END IF
  44. is_CellType=Upper(Trim(is_CellType))
  45. IF is_CellType='S' Then
  46. lb_unicode_value=invo_WorkSheet.invo_sub.to_unicode(invo_WorkSheet.invo_sub.of_str2xls(is_Value))
  47. if isnull(lb_unicode_value) then
  48. lb_unicode_value = blob("")
  49. end if
  50. ll_sst_index = invo_WorkSheet.invo_workbook.event ue_add_unicode(lb_unicode_value)
  51. ab_data = invo_WorkSheet.invo_sub.of_pack("v", row -1 ) + invo_WorkSheet.invo_sub.of_pack("v", col -1) + invo_WorkSheet.invo_sub.of_pack("v", ii_xf) + invo_WorkSheet.invo_sub.of_pack("V", ll_sst_index)
  52. li_ret=2
  53. ELSE
  54. //IF row=10 and (col=9 or col=16) then
  55. // setprofilestring("ng.ini","database",string(col),is_value+" "+string(ii_xf,"0000")+" "+invo_format.of_get_format_key())
  56. //end if
  57. IF is_CellType='N' Then
  58. ld_val=Double(is_Value)
  59. ELSEIF is_CellType='DT' Then
  60. //2004-11-17
  61. //ldt_dateTime=DateTime(Blob(is_Value)) // 这条语句在pb6.5版本不能正常计算
  62. //lt_time = time(ldt_dateTime)
  63. li_Pos=Pos(is_Value," ")
  64. IF li_Pos>0 Then
  65. lt_Time=Time(Mid(is_Value ,li_Pos+1))
  66. is_Value = Left( is_Value ,li_Pos -1)
  67. ELSE
  68. lt_Time=Time("00:00:00")
  69. END IF
  70. IF Not IsDate(is_Value) Then
  71. is_Value="1900-01-01"
  72. END IF
  73. li_hour = hour(lt_time)
  74. li_minute = minute(lt_time)
  75. li_second = second(lt_time)
  76. ld_val = daysafter(date("1899-12-30"), date(is_Value)) + (li_second + li_minute * 60 + li_hour * 3600) / ( 24 * 3600 )
  77. ELSEIF is_CellType='D' Then
  78. ld_val = daysafter(date("1899-12-30"), Date(is_Value) ) //1899-12-30 是1900/01/01的前两天
  79. ELSEIF is_CellType='T' Then
  80. lt_time = time(is_Value)
  81. li_hour = hour(lt_time)
  82. li_minute = minute(lt_time)
  83. li_second = second(lt_time)
  84. ld_val = (li_second + li_minute * 60 + li_hour * 3600) / ( 24 * 3600)
  85. END IF
  86. ab_data = invo_WorkSheet.invo_sub.of_pack("v", row -1 ) + invo_WorkSheet.invo_sub.of_pack("v", col -1 ) + invo_WorkSheet.invo_sub.of_pack("v", ii_xf) + invo_WorkSheet.invo_sub.of_pack("d",ld_val )
  87. li_ret=3
  88. END IF
  89. return li_ret
  90. end function
  91. public function blob of_getformatonly (readonly unsignedinteger ai_row, readonly unsignedinteger ai_col);Return invo_WorkSheet.invo_sub.of_pack("v", ai_row -1) + invo_WorkSheet.invo_sub.of_pack("v", ai_col -1 ) + invo_WorkSheet.invo_sub.of_pack("v", ii_xf)
  92. end function
  93. on n_xls_cell.create
  94. call super::create
  95. TriggerEvent( this, "constructor" )
  96. end on
  97. on n_xls_cell.destroy
  98. TriggerEvent( this, "destructor" )
  99. call super::destroy
  100. end on
  101. event constructor;invo_Format=Create n_xls_Format
  102. end event
  103. event destructor;Destroy invo_Format
  104. end event