CExcelXMLHTMLTable.class


SUBMITTED BY: Guest

DATE: July 23, 2014, 12:15 p.m.

FORMAT: Text only

SIZE: 10.0 kB

HITS: 967

  1. <?php
  2. include_once 'CHTMLTable.class';
  3. class CExcelXMLHTMLTable extends CHTMLTable{
  4. var $version = '1.1a';
  5. var $author_info = 'Sergey Ovchinnikov <sergeyvo@ngs.ru>, ICQ UIN 91792005';
  6. var $Styles;
  7. var $active_styles;
  8. var $default_styles;
  9. #===============================================================================================
  10. # PRINT OPEN TABLE
  11. #===============================================================================================
  12. function printOpenTable() {
  13. $default = $this->default_styles;
  14. $this->Table['border'] = $default['table_border'];
  15. $this->Table['bordercolor'] = $default['table_bordercolor'];
  16. $this->Table['cellspacing'] = $default['table_cellspacing'];
  17. $this->Table['cellpadding'] = $default['table_cellpadding'];
  18. $this->Table['style'] = $default['table_style'];
  19. echo "\n\r<TABLE";
  20. foreach($this->table_properties as $key=>$property) {
  21. if (strval($this->Table[$this->table_properties[$key]])!='') {
  22. echo " ".$key."=\"".strval($this->Table[$this->table_properties[$key]])."\"";
  23. }
  24. }
  25. echo ">\n\r";
  26. }
  27. #===============================================================================================
  28. # PRINT CLOSE TABLE
  29. #===============================================================================================
  30. function printCloseTable() {
  31. echo "<TR height=\"0\">\n";
  32. $Active = $this->active_styles;
  33. $Default = $this->default_styles;
  34. for($j=0; $j<$this->range_cols; $j++) {
  35. if (strval($Active['column_width'])=='on') {
  36. $width = $this->Table['ColumnProperties'][$j]['Width'];
  37. if (strval($this->Table['ColumnProperties'][$j]['Width'])=='' && strval($Default['column_width'])!='') {
  38. $width = $Default['column_width'];
  39. }
  40. }
  41. elseif(strval($Default['column_width'])!='') {
  42. $width = $Default['column_width'];
  43. }
  44. // $width = $this->table['ColumnProperties'][$j]['Width'];
  45. // if(!$width) $width = 64;
  46. echo " <TD width=\"".$width."\"></TD>\n";
  47. // style=\"border-bottom: none;border-top: none;border-left: none;border-bottom: right;\"
  48. }
  49. echo "</TR>\n";
  50. echo "</TABLE>\n\r\n\r";
  51. }
  52. #===============================================================================================
  53. # PRINT OPEN TR
  54. #===============================================================================================
  55. function printOpenTR($tr) {
  56. $Active = $this->active_styles;
  57. $Default = $this->default_styles;
  58. if (strval($Active['row_height'])=='on') {
  59. if (strval($tr[$this->tr_properties['height']])=='' && strval($Default['row_height'])!='') {
  60. $tr[$this->tr_properties['height']] = $Default['row_height'];
  61. }
  62. }
  63. elseif(strval($Default['row_height'])!='') {
  64. $tr[$this->tr_properties['height']] = $Default['row_height'];
  65. }
  66. echo "<TR";
  67. foreach($this->tr_properties as $key=>$property) {
  68. if (strval($tr[$this->tr_properties[$key]])!='') {
  69. echo " ".$key."=\"".strval($tr[$this->tr_properties[$key]])."\"";
  70. }
  71. }
  72. echo ">\n\r";
  73. }
  74. #===============================================================================================
  75. # PRINT OPEN TD
  76. #===============================================================================================
  77. function printTD($td) {
  78. $Styles = $this->Styles;
  79. $Active = $this->active_styles;
  80. $Default = $this->default_styles;
  81. echo " <TD";
  82. foreach($this->td_properties as $key=>$property) {
  83. if (strval($td[$this->td_properties[$key]])!='' && $key!='content') {
  84. echo " ".$key."=\"".strval($td[$this->td_properties[$key]])."\"";
  85. }
  86. }
  87. if (strval($Active['text_align'])=='on') {
  88. if (strval($Styles[$td['StyleID']]['Alignment']['Horizontal'])!='') $align = $Styles[$td['StyleID']]['Alignment']['Horizontal'];
  89. elseif(strval($Default['text_align'])!='') $align = strval($Default['text_align']);
  90. if($td['Type']=='Number' && $Active['number_format']=='on' && !$Styles[$td['StyleID']]['Alignment']['Horizontal']) $align = 'right';
  91. }
  92. else {
  93. if(strval($Default['text_align'])!='') $align = strval($Default['text_align']);
  94. if($td['Type']=='Number' && $Active['number_format']=='on') $align = 'right';
  95. }
  96. if ($align) echo " align=\"".$align."\"";
  97. if (strval($Active['text_valign'])=='on') {
  98. if (strval($Styles[$td['StyleID']]['Alignment']['Vertical'])!='') $valign = $Styles[$td['StyleID']]['Alignment']['Vertical'];
  99. elseif(strval($Default['text_valign'])!='') $valign = strval($Default['text_valign']);
  100. }
  101. else {
  102. if(strval($Default['text_valign'])!='') $valign = strval($Default['text_valign']);
  103. }
  104. if ($valign) echo " valign=\"".$valign."\"";
  105. if (strval($Active['bg_color'])=='on') {
  106. if (strval($Styles[$td['StyleID']]['Interior']['Color'])!='') $bg_color = $Styles[$td['StyleID']]['Interior']['Color'];
  107. elseif(strval($Default['bg_color'])!='') $bg_color = strval($Default['bg_color']);
  108. }
  109. else {
  110. if(strval($Default['bg_color'])!='') $bg_color = strval($Default['bg_color']);
  111. }
  112. if ($bg_color) echo " bgColor=\"".$bg_color."\"";
  113. $style = '';
  114. if (strval($Active['font_size'])=='on') {
  115. if (strval($Styles[$td['StyleID']]['Font']['Size'])!='') $font_size = $Styles[$td['StyleID']]['Font']['Size'];
  116. elseif(strval($Default['font_size'])!='') $font_size = strval($Default['font_size']);
  117. }
  118. else {
  119. if(strval($Default['font_size'])!='') $font_size = strval($Default['font_size']);
  120. }
  121. if ($font_size) $style.="font-size: ".$font_size."pt; ";
  122. if (strval($Active['font_family'])=='on') {
  123. if (strval($Styles[$td['StyleID']]['Font']['FontName'])!='') $font_family = $Styles[$td['StyleID']]['Font']['FontName'];
  124. elseif(strval($Default['font_family'])!='') $font_family = strval($Default['font_family']);
  125. }
  126. else {
  127. if(strval($Default['font_family'])!='') $font_family = strval($Default['font_family']);
  128. }
  129. if ($font_family) $style.="font-family: ".$font_family."; ";
  130. if (strval($Active['font_color'])=='on') {
  131. if (strval($Styles[$td['StyleID']]['Font']['Color'])!='') $font_color = $Styles[$td['StyleID']]['Font']['Color'];
  132. elseif(strval($Default['font_color'])!='') $font_color = strval($Default['font_color']);
  133. }
  134. else {
  135. if(strval($Default['font_color'])!='') $font_color = strval($Default['font_color']);
  136. }
  137. if ($font_color) $style.="color: ".$font_color."; ";
  138. if (strval($Active['font_bold'])=='on') {
  139. if (strval($Styles[$td['StyleID']]['Font']['Bold'])!='') $font_bold = $Styles[$td['StyleID']]['Font']['Bold'];
  140. elseif(strval($Default['font_bold'])!='') $font_bold = strval($Default['font_bold']);
  141. }
  142. else {
  143. if(strval($Default['font_bold'])!='') $font_bold = strval($Default['font_bold']);
  144. }
  145. if ($font_bold) $style.="font-weight: bold; ";
  146. if (strval($Active['font_italic'])=='on') {
  147. if (strval($Styles[$td['StyleID']]['Font']['Italic'])!='') $font_italic = $Styles[$td['StyleID']]['Font']['Italic'];
  148. elseif(strval($Default['font_italic'])!='') $font_italic = strval($Default['font_italic']);
  149. }
  150. else {
  151. if(strval($Default['font_italic'])!='') $font_italic = strval($Default['font_italic']);
  152. }
  153. if ($font_italic) $style.="font-style: italic; ";
  154. if (strval($Active['font_underline'])=='on') {
  155. if (strval($Styles[$td['StyleID']]['Font']['Underline'])!='') $font_underline = $Styles[$td['StyleID']]['Font']['Underline'];
  156. elseif(strval($Default['font_underline'])!='') $font_underline = strval($Default['font_underline']);
  157. }
  158. else {
  159. if(strval($Default['font_underline'])!='') $font_underline = strval($Default['font_underline']);
  160. }
  161. if ($font_underline) $style.="text-decoration: underline; ";
  162. if ($style) echo " style=\"".$style."\"";
  163. echo ">";
  164. if ($td[$this->td_properties['content']]) echo $td[$this->td_properties['content']];
  165. else echo '&nbsp;';
  166. echo "</TD>\n\r";
  167. }
  168. }
  169. ?>

comments powered by Disqus