$PBExportHeader$n_dw2xls_object.sru forward global type n_dw2xls_object from nonvisualobject end type end forward global type n_dw2xls_object from nonvisualobject end type global n_dw2xls_object n_dw2xls_object type prototypes end prototypes type variables Long x1 , y1 ,x2,y2 Long Original_X1, Original_Y1, Original_x2, Original_Y2 Long Width , Height String X_EXP , Y_Exp , Width_Exp , Height_Exp int startrow =1 Int endrow=1 Int startcol = 0 Int endcol =0 int rowInDetail =1 int ObjSpace string name String objType string colType Int ColID Boolean IsCloneColumn //是否复制后的数据列,如例 数据列 Dept显示部门代码 dept_1是复制的列,用于显示部门名称 Boolean IsGetDisplayValue String EditStyle Boolean CellHasMultiObjects Boolean DynamicPosition Boolean PositionChanged Boolean IsForeGround Boolean Visible=TRUE string visibleExp Boolean AutoHeight //字体属性 string fontName string fontNameExp int fontsize string fontSizeExp boolean fontBold string fontBoldExp boolean fontUnderline String fontUnderlineExp boolean fontItalic String fontItalicExp Boolean fontStrikeout String fontStrikeoutExp String alignment string format string formatExp long color string colorExp Long bkColor String bkColorExp int halignment int vAlignment =1 Boolean WrapText String BorderStyle='0' //增加对CheckBox 文本诉输出 Boolean IsCheckBox Boolean CheckBox_LeftText String CheckBox_Text String CheckBox_On String CheckBox_Off //图片 Boolean IsPicture Boolean IsGraph String PictureName String PictureExp Int Picture_OffsetX Int Picture_OffSetY Boolean NoContaint Boolean IsBorderOnly Boolean SkipBorder Boolean IsSparse Long LastWriteValueRow n_dw2xls_Object inv_PriorSparseObject Any PriorRowValue Boolean IsSlideup Long LastRow n_dw2xls_Object inv_SlideupObject[] n_dw2xls_Object inv_SlideLeftObject Int fontIndex=-1 Int xfIndex=-1 Boolean WritedFormat //是否已输入格式,用于判断是否用过GetXF来提高效率 String Text String TextExp Int TextWidth Int TextHeight Int SpaceCharWidth Int SpaceCharHeight n_dw2xls_requestor inv_Requestor n_dw2xls_requestor inv_Report n_dw2xls_Band inv_Band //四条边线 n_dw2xls_Line inv_LeftLine n_dw2xls_Line inv_RightLine n_dw2xls_Line inv_TopLine n_dw2xls_Line inv_BottomLine Boolean ib_HasBorder //与当前对象相靠近的对象 n_dw2xls_object inv_LeftObject n_dw2xls_Object inv_RightObject n_dw2xls_Object inv_UpObject n_dw2xls_Object inv_DownObject n_dw2xls_Object inv_SlideLeftObjects[] end variables forward prototypes public subroutine of_setcoltype (string as_coltype) public subroutine of_setreport (n_dw2xls_requestor anv_report) public subroutine of_setrequestor (readonly n_dw2xls_requestor anv_requestor, readonly n_dw2xls_band anv_band, readonly string as_type, readonly string as_name) public function boolean of_updateposition (readonly long al_row) public subroutine of_addslideupobject (n_dw2xls_object anv_object) public function Long of_getlastrow () public subroutine of_setposition (readonly long ai_x1, readonly long ai_y1, readonly long ai_x2, readonly long ai_y2, readonly string as_x_exp, readonly string as_y_exp, readonly string as_width_exp, readonly string as_height_exp) public function Long of_gettextrect_x1 () public function Long of_gettextrect_x2 () public function long of_gettextrect_y2 () public function Long of_getlastwritevaluerow () end prototypes public subroutine of_setcoltype (string as_coltype);IF as_ColType="?" OR as_ColType="!" Then as_ColType="" END IF IF Left(as_ColType,4)="char" Then ColType="char" ELSE ColType = as_ColType END IF Choose Case ColType Case 'char' PriorRowValue ='' Case "datetime" PriorRowValue = DateTime(1900-01-01,00:00:00) Case "date" PriorRowValue = 1900-01-01 Case "time" PriorRowValue=00:00:00 Case Else PriorRowValue =0 END CHOOSE end subroutine public subroutine of_setreport (n_dw2xls_requestor anv_report);inv_Report = anv_Report end subroutine public subroutine of_setrequestor (readonly n_dw2xls_requestor anv_requestor, readonly n_dw2xls_band anv_band, readonly string as_type, readonly string as_name);Long li_Row String ls_Value, ls_Exp n_dw2xls_Layout lnv_Layout n_dw2xls_WinApi lnv_Api IF Not IsValid(anv_requestor) THen Return END IF IF Not IsValid(anv_Band) THen Return END IF inv_Requestor = anv_requestor inv_Band = anv_Band lnv_Layout = anv_requestor.OF_GetLayout() lnv_Api = anv_Requestor.OF_GetWinApi() objType =Lower(Trim(as_Type)) name = Lower(Trim( as_Name )) ls_Value =inv_Band.OF_GetName() IF inv_Requestor.OF_RowCount()=1 Then li_Row =1 ELSEIF inv_Requestor.OF_RowCount()>1 Then IF ls_Value="summary" OR ls_Value="footer" Then li_Row =inv_Requestor.OF_RowCount() ELSEIF ls_Value="header" OR Pos(ls_Value,"header[")>0 Then li_Row =1 END IF END IF ls_Value =anv_requestor.OF_Describe(name+".SlideUp") IF ls_Value='directlyabove' OR ls_Value ="allabove" Then IsSlideup=true ELSE IsSlideup=False END IF IF objType="report" Then IF Not anv_requestor.OF_InitialReport(This, This.X1, This.Y1, This.X2, This.Y2) Then Destroy inv_Report objType="tempobj" END IF Return ELSEIF objType="column" OR objType="compute" Then OF_SetColType( anv_requestor.OF_Describe(name+".ColType") ) EditStyle =anv_Requestor.OF_Describe(name+".Edit.Style") IF EditStyle="ddlb" OR EditStyle="dddw" OR EditStyle="radiobuttons" Then IsGetDisplayValue =TRUE ELSE IF anv_Requestor.OF_Describe(name+".Edit.CodeTable")="yes" OR anv_Requestor.OF_Describe(name+".EditMask.CodeTable")="yes" Then IsGetDisplayValue =TRUE END IF END IF END IF IF IsGetDisplayValue Then PriorRowValue="" END IF //取对象的实际大小,跟x2 - X1不一定完全相同 anv_requestor.OF_GetProperty(name,"Width", ls_Value, ls_Exp) Width = Long(ls_Value) anv_requestor.OF_GetProperty(name,"Height", ls_Value, ls_Exp) Height = Long(ls_Value) IF anv_requestor.OF_Describe(name,"Height.AutoSize")="yes" Then AutoHeight=TRUE ELSE AutoHeight=False END IF IF anv_requestor.OF_GetUnits()='1' Then Width = PixelsToUnits(Width, XPixelsToUnits!) Height = PixelsToUnits(Height, YPixelsToUnits!) ELSEIF anv_requestor.OF_GetUnits()='2' Then Width = PixelsToUnits(lnv_Api.OF_InchToPixels(Width/1000 ) , XPixelsToUnits!) Height = PixelsToUnits(lnv_Api.OF_InchToPixels(Height/1000) , YPixelsToUnits!) ELSEIF anv_requestor.OF_GetUnits()='3' Then Width = PixelsToUnits(lnv_Api.OF_CMToPixels(Width /1000), XPixelsToUnits!) Height = PixelsToUnits(lnv_Api.OF_CMToPixels(Height /1000 ), YPixelsToUnits!) END IF //字体属性 anv_requestor.OF_GetProperty(name,"Font.Face", ls_Value, ls_Exp) FontName = ls_Value FontNameExp = ls_Exp anv_requestor.OF_GetProperty(name,"Font.Height", ls_Value, ls_Exp) fontSize = Long(ls_Value) IF FontSize>0 Then FontSize = lnv_Api.OF_GetFontSize(fontSize, inv_Requestor.OF_GetUnits()) ELSE FontSize =Abs(FontSize) END IF FontSizeExp = ls_Exp anv_requestor.OF_GetProperty(name,"Font.Weight", ls_Value, ls_Exp) IF Long(ls_Value)>=700 Then fontBold=TRUE ELSE fontBold=False END IF fontBoldExp = ls_Exp anv_requestor.OF_GetProperty(name,"Font.Italic", ls_Value, ls_Exp) IF ls_Value="1" OR ls_Value="yes" Then fontItalic=TRUE ELSE fontItalic=False END IF fontItalicExp =ls_Exp anv_requestor.OF_GetProperty(name,"Font.Underline", ls_Value, ls_Exp) IF ls_Value="1" OR ls_Value="yes" Then fontUnderline=TRUE ELSE fontUnderline=False END IF fontUnderlineExp =ls_Exp anv_requestor.OF_GetProperty(name,"Font.Strikethrough", ls_Value, ls_Exp) IF ls_Value="1" OR ls_Value="yes" Then fontStrikeout=TRUE ELSE fontStrikeout=False END IF fontStrikeoutExp =ls_Exp IF EditStyle="checkbox" Then IsCheckBox = TRUE CheckBox_Text = anv_requestor.OF_Describe(name+".CheckBox.Text") CheckBox_On = anv_requestor.OF_Describe(name+".CheckBox.On") CheckBox_Off = anv_requestor.OF_Describe(name+".CheckBox.Off") IF anv_requestor.OF_Describe(name+".CheckBox.LeftText")="yes" Then CheckBox_LeftText =TRUE END IF END IF IF ColType='char' Then Format="@" ELSE IF EditStyle="editmask" Then Format = anv_requestor.OF_Describe(name+".EditMask.Mask") IF Format="!" OR Format="?" Then Format="" END IF ELSE anv_requestor.OF_GetProperty(name,"Format", ls_Value, ls_Exp) IF ls_Value<>"" OR ls_Exp<>"" Then anv_requestor.OF_DataFormat(ls_Value, ls_Exp, ColType) //对数据格式进行处理,以与Excel中的数据格式一致 Format = ls_Value FormatExp = ls_Exp END IF END IF END IF alignment= anv_requestor.OF_Describe(name,"Alignment" ) IF alignment="1" Then //Right halignment = lnv_Api.HALIGN_RIGHT ELSEIF alignment='2' Then //Center halignment = lnv_Api.HALIGN_CENTER ELSE halignment = lnv_Api.HALIGN_LEFT END IF BorderStyle= anv_requestor.OF_Describe(name,"Border" ) anv_requestor.OF_GetProperty(name,"Color" ,ls_Value, ls_Exp) Color =lnv_Api.OF_GetColor( Long(ls_Value) ) ColorExp = ls_Exp IF Not anv_requestor.OF_IsWriteBKColor() Then BKColor =inv_Band.COLOR_TRANSPARENT ELSE IF anv_requestor.OF_Describe(Name,"BackGround.Mode")="1" Then BKColor =inv_Band.COLOR_TRANSPARENT ELSE anv_requestor.OF_GetProperty(name,"BackGround.Color" ,ls_Value, ls_Exp) IF IsNumber(ls_Value) Then BKColor =lnv_Api.OF_GetColor( Long( ls_Value)) ELSE BKColor =inv_Band.COLOR_TRANSPARENT END IF BKColorExp = ls_Exp END IF END IF IF objType="bitmap" Then IsPicture =TRUE PictureName= anv_Requestor.OF_Describe(name+".FileName") ELSEIF objType="column" Then IF anv_Requestor.OF_Describe(name+".BitMapName")="yes" Then isPicture=TRUE END IF ELSEIF objType="compute" AND colType="char" Then ls_Exp= Lower(anv_Requestor.OF_Describe(name+".Expression")) IF Left(ls_Exp,6)="bitmap" Then PictureExp = Trim(Mid(ls_Exp , 7 )) IF Left(PictureExp,1)="(" AND Right(PictureExp,1)=")" Then isPicture=TRUE END IF END IF ELSEIF objType="graph" Then IsGraph =TRUE IF anv_Requestor.OF_IsChild()=False AND anv_Requestor.OF_GetProcessing()='3' Then x1= 0 y1= 0 x2 = anv_Requestor.OF_GetControlWidth() Y2 = anv_Requestor.OF_GetControlHeight() Width = x2 Height = y2 END IF END IF IF isPicture Then IF inv_Band.of_GetName()="detail" Then lnv_Layout.OF_IncreaseProgress_Picture(inv_Requestor.OF_RowCount() ) ELSE lnv_Layout.OF_IncreaseProgress_Picture(1) END IF lnv_Layout.OF_SetHasPictures(TRUE) ELSEIF IsGraph =TRUE Then lnv_Layout.OF_IncreaseProgress_Picture(1) lnv_Layout.OF_SetHasPictures(TRUE) END IF IF objType="text" AND BorderStyle='2' Then ls_Value= anv_requestor.OF_Describe(as_Name+".Text") IF ls_Value="" OR ls_Value="!" OR ls_Value="?" Then IsBorderOnly =TRUE END IF END IF //计算文本的实际输出位置,为行列判断提供依据 IF IsPicture=False AND IsBorderOnly=False Then IF objType="text" Then inv_Requestor.OF_GetProperty(Name,"Text", Text, TextExp) IF ( Text<>"" AND TextExp="" AND FontNameExp="" AND FontSizeExp="" AND FontBoldExp="" AND & inv_Requestor.OF_GetProcessing()<>'1' AND inv_Requestor.OF_GetProcessing()<>'4' ) OR anv_Band.OF_GetName()<>'detail' OR IsForeGround =TRUE Then lnv_Api.OF_CalcTextRect(Text, FontName, FontSize, FontBold, Width, Height+20, Alignment, AutoHeight, TextWidth, TextHeight ,SpaceCharWidth ,SpaceCharHeight, WrapText ) END IF IF Text="" Then NoContaint=TRUE ELSEIF AutoHeight Then Y2 = Y1 + TextHeight inv_Band.OF_UpdateBandHeight(Y2) END IF ELSEIF objType="column" OR objType="compute" Then ls_Value ="" IF li_Row>0 Then ls_Value =inv_Requestor.OF_GetText(li_Row,Name,ColType, Format) IF ls_Value="" Then NoContaint=TRUE ELSE //加入空格,尽量计算时有足够的宽度可以显示 ls_Value+=" " END IF END IF IF ls_Value="" Then ls_Value=" " END IF IF ( inv_Requestor.OF_GetProcessing()<>'1' AND inv_Requestor.OF_GetProcessing()<>'4' ) OR anv_Band.OF_GetName()<>'detail' OR IsForeGround =TRUE Then lnv_Api.OF_CalcTextRect(ls_Value, FontName, FontSize, FontBold, Width, Height+20, Alignment, AutoHeight, TextWidth, TextHeight ,SpaceCharWidth ,SpaceCharHeight, WrapText) END IF IF li_Row=0 Then TextWidth =0 END IF IF AutoHeight Then IF li_Row=0 Then TextHeight =0 ELSE Y2 = Y1 + TextHeight inv_Band.OF_UpdateBandHeight(Y2) END IF END IF IF colType="char" AND SpaceCharHeight>0 Then WrapText = Int((Height+20)/SpaceCharHeight)>1 END IF END IF END IF IF colType<>'char' AND objType<>'text' AND IsGetDisplayValue=False Then WrapText =False ELSEIF AutoHeight Then WrapText =TRUE END IF IF WrapText AND ( ColType="char" OR ObjType="text") Then Format="" FormatExp="" END IF IF ObjType="column" Then ColID = Long(inv_Requestor.OF_Describe(Name+".ID")) IF inv_Requestor.OF_Describe("#"+String(ColID)+".Name")<> Name Then IsCloneColumn=TRUE END IF END IF end subroutine public function boolean of_updateposition (readonly long al_row);Long li_Value , li_Width String ls_Value Boolean lb_RowInfoChange n_dw2xls_winapi lnv_Api n_dw2xls_Layout lnv_Layout lb_RowInfoChange =False IF Not IsValid(inv_Requestor) Then Return lb_RowInfoChange END IF IF al_Row<=0 Then Return lb_RowInfoChange END IF lnv_Api = inv_Requestor.OF_GetWinApi() lnv_Layout = inv_Requestor.OF_GetLayout() IF X_EXP<>'' AND IsValid(inv_LeftLine)=False Then ls_Value =inv_Requestor.OF_Evaluate(al_Row,X_EXP) IF IsNumber(ls_Value) Then li_Value = Long(ls_Value) IF inv_Requestor.OF_GetUnits()='1' Then li_Value = PixelsToUnits(Width, XPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='2' Then li_Value = PixelsToUnits(lnv_Api.OF_InchToPixels(Width/1000 ) , XPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='3' Then li_Value = PixelsToUnits(lnv_Api.OF_CMToPixels(Width /1000), XPixelsToUnits!) END IF IF li_Value<>X1 Then X1 = li_Value startcol =lnv_Layout.OF_GetEndColumn(inv_Requestor.OF_GetReport_X1() + X1) END IF END IF END IF IF Y_EXP<>'' Then ls_Value =inv_Requestor.OF_Evaluate(al_Row,Y_EXP) IF IsNumber(ls_Value) Then li_Value = Long(ls_Value) IF inv_Requestor.OF_GetUnits()='1' Then li_Value = PixelsToUnits(Width, YPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='2' Then li_Value = PixelsToUnits(lnv_Api.OF_InchToPixels(Width/1000 ) , YPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='3' Then li_Value = PixelsToUnits(lnv_Api.OF_CMToPixels(Width /1000), YPixelsToUnits!) END IF IF li_Value<>Y1 Then lb_RowInfoChange =TRUE Y1 = li_Value END IF END IF END IF IF Width_EXP<>'' Then ls_Value =inv_Requestor.OF_Evaluate(al_Row,Width_EXP) IF IsNumber(ls_Value) Then li_Value = Long(ls_Value) IF inv_Requestor.OF_GetUnits()='1' Then li_Value = PixelsToUnits(Width, XPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='2' Then li_Value = PixelsToUnits(lnv_Api.OF_InchToPixels(Width/1000 ) , XPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='3' Then li_Value = PixelsToUnits(lnv_Api.OF_CMToPixels(Width /1000), XPixelsToUnits!) END IF IF li_Value<>Width Then Width = li_Value X2=X1 + Width EndCol =lnv_Layout.OF_GetEndColumn(inv_Requestor.OF_GetReport_X1() + X2) END IF END IF END IF IF AutoHeight Then IF objType="column" OR objType="compute" Then ls_Value ="" IF al_Row>0 Then ls_Value =inv_Requestor.OF_GetText(al_Row,Name,ColType, Format) END IF IF ls_Value="" Then TextHeight=0 WrapText=False ELSE li_Width = lnv_Layout.OF_GetColumn_X2(EndCol) - lnv_Layout.OF_GetColumn_X1(StartCol) lnv_Api.OF_CalcTextRect(ls_Value, FontName, FontSize, FontBold, li_Width, Height, Alignment, AutoHeight, TextWidth, TextHeight ,SpaceCharWidth ,SpaceCharHeight, WrapText) IF colType="char" AND SpaceCharHeight>0 Then WrapText = Int((Height+20)/SpaceCharHeight)>1 END IF END IF TextWidth =0 IF TextHeight<>Height Then Height = TextHeight lb_RowInfoChange =TRUE END IF END IF ELSE IF Height_EXP<>'' Then ls_Value =inv_Requestor.OF_Evaluate(al_Row,Height_EXP) IF IsNumber(ls_Value) Then li_Value = Long(ls_Value) IF inv_Requestor.OF_GetUnits()='1' Then li_Value = PixelsToUnits(Width, YPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='2' Then li_Value = PixelsToUnits(lnv_Api.OF_InchToPixels(Width/1000 ) , YPixelsToUnits!) ELSEIF inv_Requestor.OF_GetUnits()='3' Then li_Value = PixelsToUnits(lnv_Api.OF_CMToPixels(Width /1000), YPixelsToUnits!) END IF IF li_Value<>Height Then Height = li_Value lb_RowInfoChange =TRUE END IF END IF END IF END IF X2 = X1 + Width Y2 = Y1 + Height IF X1<>Original_X1 OR X2<>Original_X2 OR Y1<>Original_Y1 OR Y2<>Original_Y2 Then PositionChanged=TRUE lb_RowInfoChange=TRUE ELSE PositionChanged=False END IF IF visibleExp<>"" Then IF inv_Requestor.OF_Evaluate(al_Row,visibleExp)="0" Then Visible=False ELSE Visible=TRUE END IF END IF Return lb_RowInfoChange end function public subroutine of_addslideupobject (n_dw2xls_object anv_object);Int li_Index li_Index= UpperBound(inv_SlideupObject) +1 inv_SlideupObject [li_Index ] = anv_Object end subroutine public function Long of_getlastrow ();Long li, li_Row,li_LastRow For li =1 TO UpperBound(inv_SlideupObject) li_Row = inv_SlideUpObject[li].OF_GetLastRow() IF li_Row>li_LastRow Then li_LastRow = li_Row END IF Next IF LastRow> li_LastRow Then li_LastRow = LastRow END IF Return li_LastRow end function public subroutine of_setposition (readonly long ai_x1, readonly long ai_y1, readonly long ai_x2, readonly long ai_y2, readonly string as_x_exp, readonly string as_y_exp, readonly string as_width_exp, readonly string as_height_exp);x1 = ai_x1 y1 = ai_y1 x2 = ai_x2 y2 = ai_y2 Original_X1 = ai_X1 Original_Y1 = aI_Y1 Original_X2 = ai_x2 Original_Y2 = ai_Y2 X_EXP = as_x_exp y_exp =as_y_exp width_exp = as_width_exp height_exp =as_height_exp IF x_exp<>'' OR y_exp<>'' or width_exp<>'' or height_exp<>'' then DynamicPosition =TRUE END IF PositionChanged=False end subroutine public function Long of_gettextrect_x1 ();IF objType="tempobj" OR objType="report" Then Return X1 END IF IF ( inv_Requestor.OF_GetProcessing()='1' OR inv_Requestor.OF_GetProcessing()='4' ) AND IsForeGround=False Then Return X1 END IF IF TextWidth>Width OR TextWidth=0 Then Return X1 END IF IF alignment='1' Then //Right Return X2 - TextWidth ELSEIF alignment='2' Then Return X1+ Ceiling( (Width - TextWidth )/2 ) ELSE Return X1 END IF end function public function Long of_gettextrect_x2 ();IF objType="tempobj" OR objType="report" Then Return X2 END IF IF ( inv_Requestor.OF_GetProcessing()='1' OR inv_Requestor.OF_GetProcessing()='4' ) AND IsForeGround=False Then Return X2 END IF IF TextWidth>Width OR TextWidth=0 Then Return X2 END IF IF Alignment='1' Then Return X2 ELSEIF Alignment='2' Then Return X2 - Int( (Width - TextWidth )/2 ) ELSE Return X1 + TextWidth END IF end function public function long of_gettextrect_y2 (); IF objType="tempobj" OR objType="report" Then Return Y2 END IF IF inv_Band.OF_GetName()="detail" Then Return Y2 END IF IF ( inv_Requestor.OF_GetProcessing()='1' OR inv_Requestor.OF_GetProcessing()='4' ) AND IsForeGround=False Then Return Y2 END IF IF BorderStyle='2' OR BorderStyle='4' Then Return Y2 END IF IF AutoHeight AND TextHeight>0 Then Return Y1 + TextHeight END IF IF TextHeight =0 OR ( Y1 + TextHeight)>Y2 Then Return Y2 ELSE Return Y1 + TextHeight END IF end function public function Long of_getlastwritevaluerow ();IF IsValid(inv_PriorSparseObject) Then Return inv_PriorSparseObject.LastWriteValueRow ELSE Return 0 END IF Return 0 end function on n_dw2xls_object.create call super::create TriggerEvent( this, "constructor" ) end on on n_dw2xls_object.destroy TriggerEvent( this, "destructor" ) call super::destroy end on