java preview wordexcel file content_java online preview of the content in Word, excel, ppt, pdf, txt documents through url [only get the text]…

Display content from various documents on the page. Logic in servlet word: BufferedInputStream bis = null; URL url = null; HttpURLConnection httpUrl = null; // Create link url = new URL(urlReal); httpUrl = (HttpURLConnection) url. openConnection();//Connect the specified resource httpUrl.connect();//Get the network input stream bis = new BufferedInputStream(httpUrl.getInputStream()) ; String bodyText = null; WordExtractor ex = new WordExtractor(bis); bodyText = ex.getText (); response.getWriter().write(bodyText); excel: BufferedInputStream bis = null; URL url = null; HttpURLConnection httpUrl = null; // Create link url = new URL(urlReal); httpUrl = (HttpURLConnection) url.openConnection();// Connect the specified resource httpUrl.connect();// Get the network input stream bis = new BufferedInputStream(httpUrl.getInputStream()); content = new StringBuffer(); HSSFWorkbook workbook = new HSSFWorkbook( bis); for (int numSheets = 0; numSheets <workbook.getNumberOfSheets(); numSheets++) { HSSFSheet aSheet &#61 ; workbook.getSheetAt(numSheets);// Get a sheet content.append(“/n”); if (null == aSheet) { continue; } for (int rowNum = 0; rowNum <= aSheet.getLastRowNum(); rowNum&#43 ;+) { content.append(“/n”); HSSFRow aRow = aSheet.getRow(rowNum); if (null == aRow) { continue; } for (short cellNum = 0; cellNum <= aRow.getLastCellNum(); cellNum++) { HSSFCell aCell = aRow.getCell(cellNum); if ( null == aCell) { continue; } if (aCell.getCellType() =&#61 ; HSSFCell.CELL_TYPE_STRING) { content.append(aCell.getRichStringCellValue() .getString()); } else if (aCell.getCellType( ) == HSSFCell.CELL_TYPE_NUMERIC) { boolean b =…

Java uses POI to extract the text content of word, Excel, PPt, txt and the author in the file attributes

Java uses POI to extract the text content and file attributes of word, Excel, PPt, txt and the author in the file attributes The first task of internship in the new company, I came into contact with POI after checking some blogs on the Internet. It provides APIs for Java to perform read and write operations on Microsoft Office files. You can download the jar package from the apache official website http://poi.apache.org/download.html View API documentation http://poi.apache.org/components/index.html 1. Create a new ordinary maven project POI has many jar packages, so I choose to import it from the maven warehouse and build an ordinary maven first. Project Then next, just rename the project 2. Add poi dependencies in pom.xml Add in tag group <dependency> <groupId>org.apache.poi</groupId> <artifactId> poi</artifactId> < version>3.17version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>3.17</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId> poi-ooxml</artifactId> <version>3.17</version> </dependency> 3. Extract word text and author At the beginning, I only knew how to check other people’s blogs to give codes, but many of them were different from what I needed, incomplete, and the package environment was different, etc. , I am always dissatisfied. The search takes time and the effect is not very good, so I try to refer directly…

PHP realizes the effect of imitating Baidu Wenku and Docin online documents (word, excel, ppt to flash), _PHP tutorial

PHP realizes the effect of imitating Baidu Library and Docin Online Document (word, excel, ppt to flash), This article describes the example of PHP realizing the effect of imitating Baidu Library and Docin Online Document . Share it with everyone for your reference, the details are as follows: Since the project needs to implement functions similar to Baidu Library, and it is a project done by myself, I thought of finding a free ready-made one to use. Everything found online is the same. As follows: Flash Paper supports the direct conversion of Office documents (.doc, .xls, .ppt) to PDF or SWF, which is very fast and has good results. Unfortunately, Flash Paper has not been updated since V2.2. After installing Flash Paper, you can directly use the command to call FlashPrinter.exe to achieve batch conversion. For example: C:\FlashPaper2.2\FlashPrinter.exe C:\Flex Technology Introduction.ppt -o C:\Flex Technology Introduction.swf Download FlashPaper. After installation, a virtual printer will appear in the printer control panel. This means that the installation is successful. I have tried 32-bit and 64-bit versions under win7 and cannot install it. Try the above command on the command line and adjust the path according to yourself. After execution, success means it can…

PHP realizes conversion of Word, excel, etc. to pdf

I recently worked on a project that required converting word and excel documents uploaded by users into PDF documents, saving and printing them. I found a lot of information on the Internet, but it was not comprehensive, so I wrote a relatively comprehensive tutorial to share. The following are the steps: 1. To install the free openOffice software, please go to openoffice.org to download the latest version. 2. JDK support, please search and download the latest version of JDK. 3. After installing openOffice, enter Dcomcnfg in Start-Run to open the component service. In Component Services?Computer?My Computer?DCOMP Configuration, select Right-click Properties on these two items to open the properties panel as shown below: Select the Security tab, click Customize on startup and activation permissions and access permissions, and add permissions for Everyone. Select the Identity tab and select Interactive User. 4. After installing openOffice, please open it once to confirm that the software can run normally, then exit and run the following commands from the command line. First go to the installation directory, for example: C:\Program Files\OpenOffice 4\program\ Execute the command: soffice -headless-accept=”socket,host=127.0.0.1,port=8100;urp;” -nofirststartwizard The software will be run in the background after success. 5. If it is a version before…

PHP realizes the effect of imitating Baidu Library and Docin online documents (word, excel, ppt to flash)_php skills-php tutorial

This article describes an example of how PHP can imitate Baidu Library and Docin Online Documentation. Share it with everyone for your reference, the details are as follows: Since the project needs to implement functions similar to Baidu Library, and it is a project done by myself, I thought of finding a free ready-made one to use. Everything found online is the same. As follows: Flash Paper supports the direct conversion of Office documents (.doc, .xls, .ppt) to PDF or SWF, which is very fast and has good results. Unfortunately, Flash Paper has not been updated since V2.2. After installing Flash Paper, you can directly use the command to call FlashPrinter.exe to achieve batch conversion. For example: C:\FlashPaper2.2\FlashPrinter.exe C:\Flex Technology Introduction.ppt -o C:\Flex Technology Introduction.swf Download FlashPaper. After installation, a virtual printer will appear in the printer control panel. This means that the installation is successful. I have tried 32-bit and 64-bit versions under win7 and cannot install it. Try the above command on the command line and adjust the path according to yourself. After execution, success means it can be used. The next step is to use PHP. PHP uses exec, or system, etc. to execute cmd commands, such…

PHP backup database code (generate word, excel, json, xml, sql)_php skills

Single table backupCode: The code is as follows: <?php class Db { var $conn; function Db($host=”localhost”,$user =”root”,$pass=”root”,$db=”test”) { if(!$this->cOnn=mysql_connect($host,$user,$pass)) die(“can’t connect to mysql sever”); mysql_select_db($db,$this->conn); mysql_query(“SET NAMES ‘UTF-8′”); } function execute($sql) { return mysql_query($sql,$this->conn); } function findCount($sql) { $result=$this->execute($sql); return mysql_num_rows($result); } function findBySql($sql) { $ array=array(); $result=mysql_query($sql); $i=0; while($row=mysql_fetch_assoc($result)) { $array[ $i]=$row; $i++; } return $array; } //Several situations of $con //Empty: return All records //array: eg. array(‘id’=>’1’) returns the record with id=1 //string: eg. ‘id=1’ returns the record with id=1 function toExtJson($table,$start=”0″,$limit=”10″,$cOns=””) { $sql=$this->generateSql($table,$cons); $totalNum=$this->findCount($sql); $result=$this->findBySql($sql.” LIMIT “.$start.” ,”.$limit); $ resultNum = count($result);//The current number of results $str=””; $str.= “{“; $str.= “‘totalCount’:’$totalNum’, “; $str.=”‘rows’:”; $str.=”[“; for($i=0;$i<$resultNum;$i++){ $str.=”{“; $count=count($result[$i]); $j=1; foreach($result[$i] as $key=>$val ) { if($j<$count) { $str.=”‘”.$key.”‘:’”.$val.”‘,”; } elseif($j==$count) { $str.=”‘”.$key.”‘:’”.$val.”‘”; } $j++; } $str.=”}”; if ($i != $resultNum-1) { $str.= “,”; } } $str.=”]”; $str.=”}”; return $str; } function generateSql($ table,$cons) { $sql=””;//sql condition $sql=”select * from “.$table; if($cons!=””) { if(is_array($cons)) { $k=0; foreach($cons as $key=>$val) { if( $k==0) { $sql.=”where ‘”; $sql.=$key; $sql.=”‘=’”; $sql .=$val.”‘”; }else { $sql.=”and ‘”; $sql.=$key; $sql.=”‘= ‘”; $sql.=$val.”‘”; } $k++; } }else { $sql.=” where ” .$cons; } } return $sql; } function toExtXml($table,$start=”0″,$limit=”10″,$ cOns=””) { $sql=$this->generateSql($table,$cons); $totalNum=$this->findCount($sql); $result= $this->findBySql($sql.” LIMIT…

PHP realizes the effect of imitating Baidu Library and Docin online documents (word, excel, ppt to flash)_PHP

This article describes an example of how PHP can imitate Baidu Library and Docin Online Documentation. Share it with everyone for your reference, the details are as follows: Since the project needs to implement functions similar to Baidu Library, and it is a project done by myself, I thought of finding a free ready-made one to use. Everything found online is the same. As follows: Flash Paper supports the direct conversion of Office documents (.doc, .xls, .ppt) to PDF or SWF, which is very fast and has good results. Unfortunately, Flash Paper has not been updated since V2.2. After installing Flash Paper, you can directly use the command to call FlashPrinter.exe to achieve batch conversion. For example: C:\FlashPaper2.2\FlashPrinter.exe C:\Flex Technology Introduction.ppt -o C:\Flex Technology Introduction.swf Download FlashPaper. After installation, a virtual printer will appear in the printer control panel. This means that the installation is successful. I have tried 32-bit and 64-bit versions under win7 and cannot install it. Try the above command on the command line and adjust the path according to yourself. After execution, success means it can be used. The next step is to use PHP. PHP uses exec, or system, etc. to execute cmd commands, such…

PHP backup database code (generate word, excel, json, xml, sql)

This article is a detailed analysis and introduction of php backup database code (generate word, excel, json, xml, sql), please refer to it if you need it Single table backupCode: The code is as follows: <?php class Db { var $conn; function Db($host=”localhost”, $user=”root”, $pass=”root”, $db=”test”) { if(!$this->cOnn=mysql_connect($host,$user,$pass)) die(“can’t connect to mysql server”); mysql_select_db($db,$this->conn); mysql_query(“SET NAMES ‘UTF-8′”); } function execute($sql) { return mysql_query($sql,$this->conn); } function findCount($sql) { $result=$this->execute($sql); return mysql_num_rows($result); } function findBySql($sql) { $array=array(); $result=mysql_query($sql); $i=0; while($row=mysql_fetch_assoc($result)) { $array[$i]=$row; $i++; } return $array; } //Several cases of $con //empty: return all records //array: eg.array(‘id’=>’1 ‘) Return the record with id=1 //string :eg. ‘id=1’ Return the record with id=1 function toExtJson($table,$start=”0″,$limit=”10″ ,$cOns=””) { $sql=$this->generateSql($table,$cons); $totalNum=$this->findCount($sql); $result=$this->findBySql($sql.” LIMIT “.$start.” ,”.$limit); $resultNum = count($result);//Current result number $str=””; $str.= “{“; $str.= “‘totalCount’:’$totalNum’,”; $str.=”‘rows’:”; $str.=”[“; for($i=0;$i<$resultNum;$i++){ $str.=”{“; $count=count($result[$i]); $j=1; foreach($result[$i] as $key=>$val) { if($j<$count) { $str.=”‘”.$key.”‘:’”.$val.”‘,”; } elseif($j==$count) { $str.=”‘”.$key.”‘:’”.$val.”‘”; } $j++; } $str.=”}”; if ($i != $resultNum-1) { $str.= “,”; } } $str.=”]”; $str.=”}”; return $str; } function generateSql($table,$cons) { $sql=””;//sql condition $sql=”select * from “.$table; if($cons!=””) { if(is_array($cons)) { $k=0; foreach($cons as $key=>$val) { if($k==0) { $sql.=”where ‘”; $sql.=$key; $sql.=”‘=’”; $sql.=$val.”‘”; } else { $sql.=”and ‘”; $sql.=$key; $sql.=”‘=’”; $sql.=$val.”‘”; } $k++; }…

ThinkPHP export CSV, Excel

In practice, the export of EXCEL is used more than the import. Here I will share with you an export CSV EXCEL export, which is simple and convenient. First, we create a new file under Thinkphp/Library/Think: Csv.class.php<?php namespace Think; class Csv { //Export csv file public function put_csv($list,$title){ $file_name=”CSV”.date(“mdHis”,time()).”.csv”; header ( 'Content-Type: application/vnd.ms-excel' ); header ( 'Content-Disposition: attachment;filename='.$file_name ); header ( 'Cache-Control: max-age=0' ); $file = fopen('php://output',”a”); $limit=1000; $calc=0; foreach ($title as $v){ $tit[]=iconv('UTF-8', 'GB2312//IGNORE',$v); } fputcsv($file,$tit); foreach ($list as $v){ $calc++; if($limit==$calc){ ob_flush(); flush(); $calc=0; } foreach ($v as $t){ $tarr[]=iconv('UTF-8', 'GB2312//IGNORE', $t); } fputcsv($file,$tarr); unset($tarr); } unset($list); fclose($file); exit(); } } ?> Then when we export, use it synchronously in the corresponding controller. $csv=new Csv(); $list=M(“members”)->field($field)->limit(10000)->select();//Query data, can be processed $csv_title=array('User ID','Username','Binding email','Binding mobile phone', ‘Registration Time’, ‘Registration IP’); $csv->put_csv($list,$csv_title);Then define the field name, which is the name of the first line, and the processed array needs to correspond to it. I personally tested the export, which is much faster than PHPEXCEL. And CSV is an intermediate format that is much better than exporting directly to excel. AD: Really free, domain name + virtual machine + enterprise mailbox = 0 yuan

PHP backup database code (generate word, excel, json, xml, sql)

Single table backupCode: The code is as follows:<?php class Db { var $conn; function Db($host=”localhost”,$user=”root”,$pass=”root”,$db=”test”) { if(!$this->cOnn=mysql_connect($host,$user,$pass)) die(“can’t connect to mysql sever”); mysql_select_db($db,$this-> conn); mysql_query(“SET NAMES ‘UTF-8′”); } function execute($sql) { return mysql_query($sql,$this ->conn); } function findCount($sql) { $result=$this->execute($sql); return mysql_num_rows($result) ; } function findBySql($sql) { $array=array(); $result=mysql_query($sql); $i=0 ; while($row=mysql_fetch_assoc($result)) { $array[$i]=$row; $i++; } return $array; } //Several situations of $con //empty: return all records //array: eg. array(‘id’=>’1’) return id= 1 record //string :eg. ‘id=1’ returns the record with id=1 function toExtJson($table,$start=”0″,$limit=”10″,$cOns=” “) { $sql=$this->generateSql($table,$cons); $totalNum=$this->findCount($sql); $result=$this- >findBySql($sql.” LIMIT “.$start.” ,”.$limit); $resultNum = count($result);//Current result number $str=””; $str.= “{“; $str.= “‘totalCount’:’$totalNum’,”; $str.=”‘rows’:”; $str.=”[ “; for($i=0;$i<$resultNum;$i++){ $str.=”{“; $count=count($result[$i]); $j=1; foreach($result[$i] as $key=>$val) { if($j<$count) { $str .=”‘”.$key.”‘:’”.$val.”‘,”; } elseif($j==$count) { $str.= “‘”.$key.”‘:’”.$val.”‘”; } $j++; } } $str.=”}”; if ($i != $resultNum-1) { &nbsptableselected = array();while ($table = mysql_fetch_row($tables)){ $cachetables[$table[0]] = $table[0]; $tableselected[$ table[0]] = 1;}$table = $cachetables;$filename = DB_NAME . “_” .date(“Y_m_d_H_i_s”) . “.sql”;$path = “sql/” . $filename;$filehandle = fopen($path, “w”);$result = mysql_query(“SHOW tables”);while ($currrow = mysql_fetch_array($ result)){ if (isset($table[$currow[0]])) { sqldumptable($currow[0], $filehandle); fwrite($ filehandle, “\n\n\n”); }}fclose($filehandle);$update_data = array(‘filename’ => $filename, ‘postdate’ => mktime());$db->insert(‘backup_db’, $update_data);// data dump functionsfunction sqldumptable($table, $fp = 0){ $tabledump = “DROP TABLE IF EXISTS ” .…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索