CExcelXMLTableShowHTML.class


SUBMITTED BY: Guest

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

FORMAT: Text only

SIZE: 12.5 kB

HITS: 1185

  1. <?php
  2. include_once('CExcelXMLHTMLTable.class');
  3. class CExcelXMLTableShowHTML {
  4. var $version = '1.0a';
  5. var $author_info = 'Sergey Ovchinnikov <sergeyvo@ngs.ru>, ICQ UIN 91792005';
  6. var $Styles;
  7. var $StylesHTML;
  8. var $Tables;
  9. var $TablesHTML;
  10. var $HTMLTable;
  11. var $active_styles = array (
  12. 'font_size' => 'on',
  13. 'font_family' => 'on',
  14. 'font_color' => 'on',
  15. 'font_bold' => 'on',
  16. 'font_italic' => 'on',
  17. 'font_underline' => 'on',
  18. 'text_align' => 'on',
  19. 'text_valign' => 'on',
  20. 'bg_color' => 'on',
  21. 'column_width' => 'on',
  22. 'row_height' => 'on',
  23. // 'border_top' => 'on',
  24. // 'border_right' => 'on',
  25. // 'border_bottom' => 'on',
  26. // 'border_left' => 'on',
  27. 'number_format' => 'on'
  28. );
  29. var $default_styles = array (
  30. 'table_border' => 1,
  31. 'table_bordercolor' => "#C0C0C0",
  32. 'table_cellspacing' => 0,
  33. 'table_cellpadding' => 0,
  34. 'table_style' => "border-collapse:collapse;",
  35. 'font_size' => '10',
  36. 'font_family' => 'Arial Cyr',
  37. 'font_color' => '#000000',
  38. 'font_bold' => '',
  39. 'font_italic' => '',
  40. 'font_underline' => '',
  41. 'text_align' => '',
  42. 'text_valign' => '',
  43. 'bg_color' => '',
  44. 'column_width' => 64,
  45. 'row_height' => 15,
  46. );
  47. #===============================================================================================
  48. # CExcelXMLTableShowHTML
  49. #===============================================================================================
  50. function CExcelXMLTableShowHTML() {
  51. $this->HTMLTable = new CExcelXMLHTMLTable();
  52. }
  53. #===============================================================================================
  54. # SET ACTIVE STYLES
  55. #===============================================================================================
  56. function setActiveStyles($active_styles) {
  57. foreach($active_styles as $key=>$property) {
  58. $this->active_styles[$key] = $property;
  59. }
  60. }
  61. #===============================================================================================
  62. # SET DEFAULT STYLES
  63. #===============================================================================================
  64. function setDefaultStyles($default_styles) {
  65. foreach($default_styles as $key=>$property) {
  66. $this->default_styles[$key] = $property;
  67. }
  68. }
  69. #===============================================================================================
  70. # SET STYLES
  71. #===============================================================================================
  72. function setStyles($styles) {
  73. $this->Styles = $styles;
  74. }
  75. #===============================================================================================
  76. # SET TABLES
  77. #===============================================================================================
  78. function setTables($tables) {
  79. $this->Tables = $tables;
  80. }
  81. #===============================================================================================
  82. # GEN STYLE SHEET
  83. #===============================================================================================
  84. function genStyleSheet($styles) {
  85. $this->Styles = $styles;
  86. $active = $this->active_styles;
  87. $default = $this->default_styles;
  88. $sHTML.= "\n\n<STYLE>\n";
  89. if (strval($default['font_size']) =='') $default['font_size'] = $this->Styles['Default']['Font']['Size'];
  90. if (strval($default['font_family']) =='') $default['font_family'] = $this->Styles['Default']['Font']['FontName'];
  91. if (strval($default['font_color']) =='') $default['font_color'] = $this->Styles['Default']['Font']['Color'];
  92. if (strval($default['font_bold']) =='') $default['font_bold'] = $this->Styles['Default']['Font']['Bold'];
  93. if (strval($default['text_align']) =='') $default['text_align'] = $this->Styles['Default']['Alignment']['Horizontal'];
  94. // if (strval($default['text_valign']) =='') $default['text_valign'] = $this->Styles['Default']['Alignment']['Vertical'];
  95. if (strval($default['background']) =='') $default['background'] = $this->Styles['Default']['Interior']['Color'];
  96. if (strval($default['border_bottom'])=='') $default['border_bottom'] = $this->Styles['Default']['Borders']['Bottom']['Weight'];
  97. if (strval($default['border_left']) =='') $default['border_left'] = $this->Styles['Default']['Borders']['Left']['Weight'];
  98. if (strval($default['border_right']) =='') $default['border_right'] = $this->Styles['Default']['Borders']['Right']['Weight'];
  99. if (strval($default['border_top']) =='') $default['border_top'] = $this->Styles['Default']['Borders']['Top']['Weight'];
  100. $defHTML = $this->createStyle($default);
  101. if ($defHTML) {
  102. $sHTML.= "TD {\n";
  103. $sHTML.= $defHTML;
  104. $sHTML.= "}\n";
  105. }
  106. foreach($this->Styles as $style_name=>$style) {
  107. if ($active['font_size'] =='on') $st['font_size'] = $style['Font']['Size'];
  108. if ($active['font_family'] =='on') $st['font_family'] = $style['Font']['FontName'];
  109. if ($active['font_color'] =='on') $st['font_color'] = $style['Font']['Color'];
  110. if ($active['font_bold'] =='on') $st['font_bold'] = $style['Font']['Bold'];
  111. if ($active['font_italic'] =='on') $st['font_italic'] = $style['Font']['Italic'];
  112. if ($active['font_underline'] =='on') $st['font_underline'] = $style['Font']['Underline'];
  113. if ($active['text_align'] =='on') $st['text_align'] = $style['Alignment']['Horizontal'];
  114. if ($active['text_valign'] =='on') $st['text_valign'] = $style['Alignment']['Vertical'];
  115. if ($active['background'] =='on') $st['background'] = $style['Interior']['Color'];
  116. if ($active['border_bottom']=='on') $st['border_bottom'] = $style['Borders']['Bottom']['Weight'];
  117. if ($active['border_left'] =='on') $st['border_left'] = $style['Borders']['Left']['Weight'];
  118. if ($active['border_right'] =='on') $st['border_right'] = $style['Borders']['Right']['Weight'];
  119. if ($active['border_top'] =='on') $st['border_top'] = $style['Borders']['Top']['Weight'];
  120. $sBody = $this->createStyle($st);
  121. if ($sBody!='') {
  122. $sHTML.= ".".$style_name." {\n";
  123. $sHTML.= $sBody;
  124. $sHTML.= "}\n";
  125. }
  126. }
  127. $sHTML.= "</STYLE>\n\n";
  128. $this->StylesHTML = $sHTML;
  129. }
  130. #===============================================================================================
  131. # CREATE STYLE
  132. #===============================================================================================
  133. function createStyle($style) {
  134. $sBody='';
  135. if (strval($style['font_size'])!='')
  136. $sBody.= " font-size: ".$style['font_size']."px;\n";
  137. if (strval($style['font_family'])!='')
  138. $sBody.= " font-family: ".$style['font_family'].";\n";
  139. if (strval($style['font_color'])!='')
  140. $sBody.= " color: ".$style['font_color'].";\n";
  141. if (strval($style['font_bold'])=='1')
  142. $sBody.= " font-weight: bold;\n";
  143. if (strval($style['font_italic'])!='')
  144. $sBody.= " font-style: italic;\n";
  145. if (strval($style['font_underline'])!='')
  146. $sBody.= " text-decoration: underline;\n";
  147. if (strval($style['text_align'])!='')
  148. $sBody.= " text-align: ".$style['text_align'].";\n";
  149. if (strval($style['text_valign'])!='')
  150. $sBody.= " vertical-align: ".$style['text_valign'].";\n";
  151. if (strval($style['background'])!='')
  152. $sBody.= " background: ".$style['background'].";\n";
  153. if (strval($style['border_top'])!='')
  154. $sBody.= " border-top: ".$style['border_top']."pt solid windowtext;\n";
  155. if (strval($style['border_right'])!='')
  156. $sBody.= " border-right: ".$style['border_right']."pt solid windowtext;\n";
  157. if (strval($style['border_bottom'])!='')
  158. $sBody.= " border-bottom: ".$style['border_bottom']."pt solid windowtext;\n";
  159. if (strval($style['border_left'])!='')
  160. $sBody.= " border-left: ".$style['border_left']."pt solid windowtext;\n";
  161. return $sBody;
  162. }
  163. #===============================================================================================
  164. # SHOW HTML STYLE SHEET
  165. #===============================================================================================
  166. function showHTMLStyleSheet($styles) {
  167. $this->Styles = $styles;
  168. $this->genStyleSheet($styles);
  169. echo $this->StylesHTML;
  170. }
  171. #===============================================================================================
  172. # GEN EXCEL TABLE
  173. #===============================================================================================
  174. function genExcelTable($tables) {
  175. }
  176. #===============================================================================================
  177. # SHOW HTML EXCEL TABLE
  178. #===============================================================================================
  179. function showHTMLExcelTable() {
  180. // $this->Tables = $tables;
  181. $td_properties = array(
  182. 'colspan' => 'Colspan',
  183. 'rowspan' => 'Rowspan',
  184. // 'class' => 'StyleID',
  185. 'content' => 'Content',
  186. );
  187. $tr_properties = array(
  188. 'height' => 'Height',
  189. );
  190. $this->HTMLTable->setTDProperties($td_properties);
  191. $this->HTMLTable->setTRProperties($tr_properties);
  192. $this->HTMLTable->Styles = $this->Styles;
  193. $this->HTMLTable->active_styles = $this->active_styles;
  194. $this->HTMLTable->default_styles = $this->default_styles;
  195. echo "<!----------------------------------------------------------------------------------->\n";
  196. echo "<!-------------------------- EXCEL TABLES ------------------------------------------>\n";
  197. echo "<!----------------------------------------------------------------------------------->\n";
  198. for ($i=0; $i<count($this->Tables); $i++) {
  199. if ($this->Tables[$i]['Table']['Rows']) {
  200. echo "<B>".$this->Tables[$i]['ListName']."</B>";
  201. $this->HTMLTable->Table = $this->Tables[$i]['Table'];
  202. $this->HTMLTable->setRangeRows($this->Tables[$i]['Table']['ExpandedRowCount']);
  203. $this->HTMLTable->setRangeCols($this->Tables[$i]['Table']['ExpandedColumnCount']);
  204. $this->HTMLTable->showTable();
  205. echo "<BR>\n";
  206. }
  207. }
  208. echo "<!----------------------------------------------------------------------------------->\n";
  209. echo "<!-------------------------- /EXCEL TABLES ----------------------------------------->\n";
  210. echo "<!----------------------------------------------------------------------------------->\n\n\n";
  211. }
  212. #===============================================================================================
  213. # / class
  214. #===============================================================================================
  215. }
  216. ?>

comments powered by Disqus