/** * options */ public function testOptions() { $e2h = new \tomk79\excel2html\main(__DIR__ . '/sample/cell_styled.xlsx'); $src = $e2h->get_html(array()); $options = $e2h->get_options(); // var_dump($src); $this->assertEquals('strict', $options['renderer']); $e2h = new \tomk79\excel2html\main(__DIR__ . '/sample/cell_styled.xlsx'); $src = $e2h->get_html(array('renderer' => 'simplify')); $options = $e2h->get_options(); // var_dump($src); $this->assertEquals('simplify', $options['renderer']); $e2h = new \tomk79\excel2html\main(__DIR__ . '/sample/utf-8.csv'); $src = $e2h->get_html(array('renderer' => 'strict')); $options = $e2h->get_options(); // var_dump($src); $this->assertEquals('simplify', $options['renderer']); $this->assertTrue($options['render_cell_width']); $this->assertFalse($options['render_cell_borders']); $e2h = new \tomk79\excel2html\main(__DIR__ . '/sample/default.xlsx'); $src = $e2h->get_html(array('header_row' => 1, 'header_col' => 1, 'renderer' => 'simplify', 'cell_renderer' => 'html', 'render_cell_width' => true, 'strip_table_tag' => true)); $options = $e2h->get_options(); // var_dump($src); $this->assertEquals('simplify', $options['renderer']); $this->assertTrue($options['render_cell_width']); $this->assertFalse($options['render_cell_borders']); }
@ini_set('mbstring.http_output', 'UTF-8'); } @ini_set('default_charset', 'UTF-8'); if (is_callable('mb_detect_order')) { @ini_set('mbstring.detect_order', 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,JIS,ASCII'); mb_detect_order('UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,JIS,ASCII'); } // var_dump($req->get_cli_options()); // var_dump($req->get_cli_option('--path')); $path_xlsx = $req->get_cli_option('--path'); $options = array('header_row' => $req->get_cli_option('--header_row'), 'header_col' => $req->get_cli_option('--header_col'), 'renderer' => $req->get_cli_option('--renderer'), 'cell_renderer' => $req->get_cli_option('--cell_renderer'), 'render_cell_width' => true, 'strip_table_tag' => true); // var_dump($path_xlsx); // var_dump($options); if (is_null($path_xlsx)) { print '<!-- ERROR: parameter path is required. -->'; exit; } if (!is_file($path_xlsx) || !is_readable($path_xlsx)) { print '<!-- ERROR: $path_xlsx is NOT a file or NOT readable. -->'; exit; } $bin = file_get_contents($path_xlsx); if (!strlen($bin)) { // print '<!-- ERROR: $path_xlsx contains NO contents. -->'; print ''; exit; } $excel2html = new \tomk79\excel2html\main($path_xlsx); $val = $excel2html->get_html($options); print $val; exit;
/** * kick as PX Command * * @return void */ private function kick() { $this->command = $this->px->get_px_command(); require_once __DIR__ . '/std_output.php'; $std_output = new std_output($this->px); switch (@$this->command[1]) { case 'ping': // 疎通確認応答 print $std_output->data_convert('ok'); exit; break; case 'version': // バージョン番号 print $std_output->data_convert($this->get_version()); exit; break; case 'check_status': // 状態をチェックする print $std_output->data_convert($this->check_status()); exit; break; case 'get': switch (@$this->command[2]) { case 'realpath_data_dir': print $std_output->data_convert($this->get_realpath_data_dir()); exit; break; case 'path_resource_dir': print $std_output->data_convert($this->get_path_resource_dir()); exit; break; case 'custom_fields': print $std_output->data_convert($this->get_custom_fields()); exit; break; } break; case 'find_page_content': // コンテンツのパスを調べる print $std_output->data_convert($this->find_page_content()); exit; break; case 'check_editor_mode': // コンテンツの編集モードを調べる print $std_output->data_convert($this->check_editor_mode()); exit; break; case 'init_content': // コンテンツを初期化する $result = $this->init_content($this->px->req()->get_param('editor_mode')); print $std_output->data_convert($result); exit; break; case 'copy_content': // コンテンツを複製する $path_to = $this->px->req()->get_request_file_path(); $param_to = $this->px->req()->get_param('to'); if (strlen($param_to)) { $path_to = $param_to; } $result = $this->copy_content($this->px->req()->get_param('from'), $path_to); print $std_output->data_convert($result); exit; break; case 'change_content_editor_mode': // コンテンツを初期化する $result = $this->change_content_editor_mode($this->px->req()->get_param('editor_mode')); print $std_output->data_convert($result); exit; break; case 'document_modules': $data_type = $this->px->req()->get_param('type'); $val = null; switch (@$this->command[2]) { case 'build_css': if (!is_string($data_type) || !strlen($data_type)) { header('Content-type: text/css; charset=UTF-8'); $this->px->req()->set_param('type', 'css'); } $val = $this->document_modules()->build_css(); break; case 'build_js': if (!is_string($data_type) || !strlen($data_type)) { header('Content-type: text/javascript; charset=UTF-8'); $this->px->req()->set_param('type', 'js'); } $val = $this->document_modules()->build_js(); break; case 'load': if (!is_string($data_type) || !strlen($data_type)) { header('Content-type: text/html; charset=UTF-8'); $this->px->req()->set_param('type', 'html'); } $val = $this->document_modules()->load(); break; } print $std_output->data_convert($val); exit; break; case 'convert_table_excel2html': $path_xlsx = $this->px->req()->get_param('path'); if (!is_file($path_xlsx) || !is_readable($path_xlsx)) { print $std_output->data_convert(false); exit; break; } $excel2html = new \tomk79\excel2html\main($path_xlsx); $val = @$excel2html->get_html(array('header_row' => $this->px->req()->get_param('header_row'), 'header_col' => $this->px->req()->get_param('header_col'), 'renderer' => $this->px->req()->get_param('renderer'), 'cell_renderer' => $this->px->req()->get_param('cell_renderer'), 'render_cell_width' => true, 'strip_table_tag' => true)); print $std_output->data_convert($val); exit; break; } print $this->px->pxcmd()->get_cli_header(); print 'Pickles 2 Desktop Tool Helper plugin.' . "\n"; print $this->px->pxcmd()->get_cli_footer(); exit; }