前期规划日志 Previous Development Plan :
>10/02/2016<
>08/03/2016<
后续开发日志 Development Update:
>10/04/2016<
>前往查询器 Use the checker<
以下为主要开发内容 The following is the main content:
近几日完成了查询器的主要开发工作并上线测试。
Main development work has been finished on these days, and the tolerance checker has been launched into beta test.
首先是确认了需要使用的php excel reader工具,资源来自SourceForge上的一个项目:<PHP-ExcelReader> ;调用方法参考了搜索到的这篇日志:<PHP ExcelReader用法>
First, excel reader tool has been selected. It is a SourceForge project:<PHP-ExcelReader>, and I find a Chinese user manual by this link:<PHP ExcelReader用法>
其调用方法是:
How to invoke the PHP-ExcelReader:
[php]
require_once ‘Excel/reader.php’;
$data = new Spreadsheet_Excel_Reader(); /*invoking reader*/
$data->setOutputEncoding(‘UTF-8’); /*text output encoding*/
$data->read(‘db.xls’); /*read the excel sheet*/
echo $data->sheets[0][‘cells’][i][j]; /*read the (i,j)cell
and output data*/
[/php]
这个基本结构是针对查固定路径的单个excel表格的,我先编写了一个3行3列excel表格进行测试,表单通过post形式将需要的单元格位置(i,j)将表单信息告知excel_reader,reader返回查询数据:
The basic code structure of this tool is used to read a single work sheet in one .xls file by solid path. So I created a 3*3 excel sheet for test. Html form choices with (i,j) cell position are sent to excel_reader by ‘post’ method, which would return and print out the checking result by code below.
[php]
echo $data->sheets[0][‘cells’][$_POST["row"]][$_POST["column"]];
[/php]
测试结果如图1, 成功!进入下一步开发。
Test was successful as fig.1! Next step.

图.1(Fig.1)
根据日志>2<中图2的逻辑与文件结构,需要查询不同路径下不同xls的文件,路径由表单输出的数据决定,所以excel_reader读取路径处不能再填写定值,故在这之前定义了一个变量$path, 同样采取post的形式获取表单数据并编写路径,然后让reader读取$path路径:
According to logic and files structure posted on fig.2 of log >2< , the checker must visit different folders and pick out the exact .xls database file from dozens of them. In other words, the file path and the name of file should be variables. So I define a $path variable which get message from the form by post method as well. And the reader will read the $path instead of solid path.
[php]
$path="db/".$_POST["type"]."/".$_POST["zone"].".xls";
……
$data->read($path);
[/php]
由于我只在一个文件夹里存放了一个db.xls文件,当我在表单选择了一个空路径的时候或者我没有填写完所有表单项却提交了表单,reader返回了”The filename …….xls is not readable”的错误信息,我意识到整个单选表单必须填写完成才能提交。搜索了许多方法,一开始发现需要通过js等工具进行表单验证,弹出提醒框等等等。踏破铁鞋无觅处得来全不费工夫,html5直接提供了表单必填的验证,在input里添上短短一句便可:
I uploaded only one db.xls file to the database folder, then I found a problem when I select a wrong path or leave some form blank —— reader told me that ‘The filename …….xls is not readable’. And I realized I must set something for form correction. So many methods told me to use js code or else when the exactly excellent answer is so simple that you should write only 2 word in the <input>, thanks to html5 :
[html]
required="required"
[/html]
剩下的就让浏览器来做就好了,如图2
The rest of the work? Browsers will do for you as fig.2!

图.2(Fig.2)
显然,如上图,我用div把表单框起来并稍微美化了一下。
Obviously, I beautified the page by <div> tag.
主要的问题都解决了,就把表单修改为正式的极限偏差查询器项目,然后上传了一个完整数据的.xls数据表,极限偏差查询器正式进入线上beta测试!
Works done and problems solved. The html form was changed into real tolerance checker type. And I uploaded the first database .xls file with useful tolerance data. It is beta test now!

下一阶段的工作目标:
Plan for next version:
- 由于我获得的极限偏差表是纸质的,所以所有数据必须手动创建.xls文件,需要实现公差查询的基本功能,这个是主要任务也是工作量最大的任务。
- 学会一些CSS的内容,将查询器美化一下。
- 学会一些Jquery、ajax的内容,将跳转显示查询结果改为在主页刷新显示查询结果,即客户端只需要显示index,同时包含表单和查询结果显示框,表单不断复用。
- Tolerance data I own is on papers. If the tolerance can function as a real one, I must type the data into computer by hand and edit .xls files manually. Hard work but necessary.
- Learn something about CSS and use it to beatify the checker’s page.
- Learn something about Jquery, ajax or else. The codes can refresh the checker index page without jumping into others. Which means, the index contain the html form and the result display on same page, visitor can reuse the form and read the result on same page, without clicking “Back to index and check again”.