{"id":345,"date":"2016-03-17T11:07:21","date_gmt":"2016-03-17T03:07:21","guid":{"rendered":"http:\/\/goyuwei.com\/blog\/?p=345"},"modified":"2016-05-03T18:01:49","modified_gmt":"2016-05-03T10:01:49","slug":"17032016-tolerance-checker-development-log-%e6%9e%81%e9%99%90%e5%81%8f%e5%b7%ae%e6%9f%a5%e8%af%a2%e5%99%a8%e5%bc%80%e5%8f%91%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"http:\/\/goyuwei.com\/blog\/?p=345","title":{"rendered":"17\/03\/2016 \u2013 Tolerance Checker Development Log\u2013 \u6781\u9650\u504f\u5dee\u67e5\u8be2\u5668\u5f00\u53d1\u65e5\u5fd7"},"content":{"rendered":"<p style=\"text-align: center;\">\u524d\u671f\u89c4\u5212\u65e5\u5fd7 Previous\u00a0Development Plan \uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=297\" target=\"_blank\">&gt;10\/02\/2016&lt;<\/a><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=320\" target=\"_blank\">&gt;08\/03\/2016&lt;<\/a><\/p>\n<hr \/>\n<p style=\"text-align: center;\">\n<p style=\"text-align: center;\">\u540e\u7eed\u5f00\u53d1\u65e5\u5fd7 Development Update\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=380\" target=\"_blank\">&gt;10\/04\/2016&lt;<\/a><\/p>\n<hr \/>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/lab\/mechanical\/tolerance_checker\/\" target=\"_blank\">&gt;\u524d\u5f80\u67e5\u8be2\u5668 Use the checker&lt;<\/a><\/p>\n<p>\u4ee5\u4e0b\u4e3a\u4e3b\u8981\u5f00\u53d1\u5185\u5bb9 The following is the main content\uff1a<\/p>\n<p>\u8fd1\u51e0\u65e5\u5b8c\u6210\u4e86\u67e5\u8be2\u5668\u7684\u4e3b\u8981\u5f00\u53d1\u5de5\u4f5c\u5e76\u4e0a\u7ebf\u6d4b\u8bd5\u3002<\/p>\n<p>Main development work has been finished\u00a0on these days, and the\u00a0tolerance checker has been launched into beta test.<\/p>\n<p>\u9996\u5148\u662f\u786e\u8ba4\u4e86\u9700\u8981\u4f7f\u7528\u7684php excel reader\u5de5\u5177\uff0c\u8d44\u6e90\u6765\u81eaSourceForge\u4e0a\u7684\u4e00\u4e2a\u9879\u76ee:<a href=\"https:\/\/sourceforge.net\/projects\/phpexcelreader\/\" target=\"_blank\">&lt;PHP-ExcelReader&gt;<\/a> ;\u8c03\u7528\u65b9\u6cd5\u53c2\u8003\u4e86\u641c\u7d22\u5230\u7684\u8fd9\u7bc7\u65e5\u5fd7:<a href=\"http:\/\/blog.sina.com.cn\/s\/blog_43b191a901011msh.html\" target=\"_blank\">&lt;PHP ExcelReader\u7528\u6cd5&gt;<\/a><\/p>\n<p>First, excel reader tool has been selected. It is a\u00a0SourceForge project:<a href=\"https:\/\/sourceforge.net\/projects\/phpexcelreader\/\" target=\"_blank\">&lt;PHP-ExcelReader&gt;<\/a>, and I find a Chinese\u00a0u<span id=\"ouHighlight__0_1TO0_3\" class=\"\">ser<\/span><span id=\"noHighlight_0.6996845449320972\"> <\/span><span id=\"ouHighlight__2_3TO5_10\" class=\"\">manual by this link:<a href=\"http:\/\/blog.sina.com.cn\/s\/blog_43b191a901011msh.html\" target=\"_blank\">&lt;PHP ExcelReader\u7528\u6cd5&gt;<\/a><\/span><\/p>\n<p>\u5176\u8c03\u7528\u65b9\u6cd5\u662f\uff1a<\/p>\n<p>How to invoke the\u00a0PHP-ExcelReader:<\/p>\n<p>[php]<br \/>\nrequire_once &#8216;Excel\/reader.php&#8217;;<br \/>\n$data = new Spreadsheet_Excel_Reader();       \/*invoking reader*\/<br \/>\n$data-&gt;setOutputEncoding(&#8216;UTF-8&#8217;);            \/*text output encoding*\/<br \/>\n$data-&gt;read(&#8216;db.xls&#8217;);                        \/*read the excel sheet*\/<\/p>\n<p>echo $data-&gt;sheets[0][&#8216;cells&#8217;][i][j];         \/*read the (i,j)cell<br \/>\n                                                 and output data*\/<br \/>\n[\/php]<\/p>\n<p>\u8fd9\u4e2a\u57fa\u672c\u7ed3\u6784\u662f\u9488\u5bf9\u67e5\u56fa\u5b9a\u8def\u5f84\u7684\u5355\u4e2aexcel\u8868\u683c\u7684\uff0c\u6211\u5148\u7f16\u5199\u4e86\u4e00\u4e2a3\u884c3\u5217excel\u8868\u683c\u8fdb\u884c\u6d4b\u8bd5\uff0c\u8868\u5355\u901a\u8fc7post\u5f62\u5f0f\u5c06\u9700\u8981\u7684\u5355\u5143\u683c\u4f4d\u7f6e(i,j)\u5c06\u8868\u5355\u4fe1\u606f\u544a\u77e5excel_reader\uff0creader\u8fd4\u56de\u67e5\u8be2\u6570\u636e\uff1a<\/p>\n<p>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\u00a0excel_reader by &#8216;post&#8217; method, which would return and print out the checking result by code below.<\/p>\n<p>[php]<\/p>\n<p>echo $data-&gt;sheets[0][&#8216;cells&#8217;][$_POST[&quot;row&quot;]][$_POST[&quot;column&quot;]];<\/p>\n<p>[\/php]<\/p>\n<p>\u6d4b\u8bd5\u7ed3\u679c\u5982\u56fe1,\u00a0\u6210\u529f!\u8fdb\u5165\u4e0b\u4e00\u6b65\u5f00\u53d1\u3002<\/p>\n<p>Test was successful as fig.1! Next step.<\/p>\n<p><a href=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-363 aligncenter\" src=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-1.jpg\" alt=\"20160317-checker_devlop_log-1\" width=\"455\" height=\"402\" srcset=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-1.jpg 455w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-1-300x265.jpg 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">\u56fe.1(Fig.1)<\/p>\n<p>\u6839\u636e\u65e5\u5fd7<a href=\"http:\/\/goyuwei.com\/blog\/?p=320\" target=\"_blank\">&gt;2&lt;<\/a>\u4e2d\u56fe2\u7684\u903b\u8f91\u4e0e\u6587\u4ef6\u7ed3\u6784\uff0c\u9700\u8981\u67e5\u8be2\u4e0d\u540c\u8def\u5f84\u4e0b\u4e0d\u540cxls\u7684\u6587\u4ef6\uff0c\u8def\u5f84\u7531\u8868\u5355\u8f93\u51fa\u7684\u6570\u636e\u51b3\u5b9a\uff0c\u6240\u4ee5excel_reader\u8bfb\u53d6\u8def\u5f84\u5904\u4e0d\u80fd\u518d\u586b\u5199\u5b9a\u503c\uff0c\u6545\u5728\u8fd9\u4e4b\u524d\u5b9a\u4e49\u4e86\u4e00\u4e2a\u53d8\u91cf$path,\u00a0\u540c\u6837\u91c7\u53d6post\u7684\u5f62\u5f0f\u83b7\u53d6\u8868\u5355\u6570\u636e\u5e76\u7f16\u5199\u8def\u5f84\uff0c\u7136\u540e\u8ba9reader\u8bfb\u53d6$path\u8def\u5f84\uff1a<\/p>\n<p>According to logic and files structure posted on fig.2 of log\u00a0<a href=\"http:\/\/goyuwei.com\/blog\/?p=320\" target=\"_blank\">&gt;2&lt;<\/a>\u00a0, 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\u00a0define a\u00a0$path\u00a0variable which get message from the form by post method as well. And the reader will read the $path instead of solid path.<\/p>\n<p>[php]<\/p>\n<p>$path=&quot;db\/&quot;.$_POST[&quot;type&quot;].&quot;\/&quot;.$_POST[&quot;zone&quot;].&quot;.xls&quot;;<\/p>\n<p>\u2026\u2026<\/p>\n<p>$data-&gt;read($path);<\/p>\n<p>[\/php]<\/p>\n<p>\u7531\u4e8e\u6211\u53ea\u5728\u4e00\u4e2a\u6587\u4ef6\u5939\u91cc\u5b58\u653e\u4e86\u4e00\u4e2adb.xls\u6587\u4ef6\uff0c\u5f53\u6211\u5728\u8868\u5355\u9009\u62e9\u4e86\u4e00\u4e2a\u7a7a\u8def\u5f84\u7684\u65f6\u5019\u6216\u8005\u6211\u6ca1\u6709\u586b\u5199\u5b8c\u6240\u6709\u8868\u5355\u9879\u5374\u63d0\u4ea4\u4e86\u8868\u5355\uff0creader\u8fd4\u56de\u4e86&#8221;The filename \u2026\u2026.xls is not readable&#8221;\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u6211\u610f\u8bc6\u5230\u6574\u4e2a\u5355\u9009\u8868\u5355\u5fc5\u987b\u586b\u5199\u5b8c\u6210\u624d\u80fd\u63d0\u4ea4\u3002\u641c\u7d22\u4e86\u8bb8\u591a\u65b9\u6cd5\uff0c\u4e00\u5f00\u59cb\u53d1\u73b0\u9700\u8981\u901a\u8fc7js\u7b49\u5de5\u5177\u8fdb\u884c\u8868\u5355\u9a8c\u8bc1\uff0c\u5f39\u51fa\u63d0\u9192\u6846\u7b49\u7b49\u7b49\u3002\u8e0f\u7834\u94c1\u978b\u65e0\u89c5\u5904\u5f97\u6765\u5168\u4e0d\u8d39\u5de5\u592b\uff0chtml5\u76f4\u63a5\u63d0\u4f9b\u4e86\u8868\u5355\u5fc5\u586b\u7684\u9a8c\u8bc1\uff0c\u5728input\u91cc\u6dfb\u4e0a\u77ed\u77ed\u4e00\u53e5\u4fbf\u53ef\uff1a<\/p>\n<p>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 \u2014\u2014 reader told me that \u2018The filename \u2026\u2026.xls is not readable\u2019. 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 &lt;input&gt;, thanks to html5 :<\/p>\n<p>[html]<\/p>\n<p>required=&quot;required&quot;<\/p>\n<p>[\/html]<\/p>\n<p>\u5269\u4e0b\u7684\u5c31\u8ba9\u6d4f\u89c8\u5668\u6765\u505a\u5c31\u597d\u4e86\uff0c\u5982\u56fe2<\/p>\n<p><span id=\"noHighlight_0.24845459638163447\">The <\/span><span id=\"ouHighlight__0_1TO4_7\">rest<\/span><span id=\"noHighlight_0.70957708847709\"> <\/span><span id=\"ouHighlight__2_2TO9_10\" class=\"\">of<\/span><span id=\"noHighlight_0.5110450177453458\"> the <\/span><span id=\"ouHighlight__3_4TO16_19\" class=\"\">work? Browsers will do for you as fig.2!<\/span><\/p>\n<p><a href=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-366 aligncenter\" src=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-2.jpg\" alt=\"20160317-checker_devlop_log-2\" width=\"806\" height=\"412\" srcset=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-2.jpg 806w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-2-300x153.jpg 300w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-2-768x393.jpg 768w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">\u56fe.2(Fig.2)<\/p>\n<p>\u663e\u7136\uff0c\u5982\u4e0a\u56fe\uff0c\u6211\u7528div\u628a\u8868\u5355\u6846\u8d77\u6765\u5e76\u7a0d\u5fae\u7f8e\u5316\u4e86\u4e00\u4e0b\u3002<\/p>\n<p>Obviously, I beautified the page by &lt;div&gt; tag.<\/p>\n<p>\u4e3b\u8981\u7684\u95ee\u9898\u90fd\u89e3\u51b3\u4e86\uff0c\u5c31\u628a\u8868\u5355\u4fee\u6539\u4e3a\u6b63\u5f0f\u7684\u6781\u9650\u504f\u5dee\u67e5\u8be2\u5668\u9879\u76ee\uff0c\u7136\u540e\u4e0a\u4f20\u4e86\u4e00\u4e2a\u5b8c\u6574\u6570\u636e\u7684.xls\u6570\u636e\u8868\uff0c\u6781\u9650\u504f\u5dee\u67e5\u8be2\u5668\u6b63\u5f0f\u8fdb\u5165\u7ebf\u4e0abeta\u6d4b\u8bd5!<\/p>\n<p>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!<\/p>\n<p><a href=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-367 aligncenter\" src=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-3.jpg\" alt=\"20160317-checker_devlop_log-3\" width=\"553\" height=\"422\" srcset=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-3.jpg 553w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/03\/20160317-checker_devlop_log-3-300x229.jpg 300w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/a><\/p>\n<p>\u4e0b\u4e00\u9636\u6bb5\u7684\u5de5\u4f5c\u76ee\u6807\uff1a<\/p>\n<p>Plan for next version:<\/p>\n<ol>\n<li>\u7531\u4e8e\u6211\u83b7\u5f97\u7684\u6781\u9650\u504f\u5dee\u8868\u662f\u7eb8\u8d28\u7684\uff0c\u6240\u4ee5\u6240\u6709\u6570\u636e\u5fc5\u987b\u624b\u52a8\u521b\u5efa.xls\u6587\u4ef6\uff0c\u9700\u8981\u5b9e\u73b0\u516c\u5dee\u67e5\u8be2\u7684\u57fa\u672c\u529f\u80fd\uff0c\u8fd9\u4e2a\u662f\u4e3b\u8981\u4efb\u52a1\u4e5f\u662f\u5de5\u4f5c\u91cf\u6700\u5927\u7684\u4efb\u52a1\u3002<\/li>\n<li>\u5b66\u4f1a\u4e00\u4e9bCSS\u7684\u5185\u5bb9\uff0c\u5c06\u67e5\u8be2\u5668\u7f8e\u5316\u4e00\u4e0b\u3002<\/li>\n<li>\u5b66\u4f1a\u4e00\u4e9bJquery\u3001ajax\u7684\u5185\u5bb9\uff0c\u5c06\u8df3\u8f6c\u663e\u793a\u67e5\u8be2\u7ed3\u679c\u6539\u4e3a\u5728\u4e3b\u9875\u5237\u65b0\u663e\u793a\u67e5\u8be2\u7ed3\u679c\uff0c\u5373\u5ba2\u6237\u7aef\u53ea\u9700\u8981\u663e\u793aindex\uff0c\u540c\u65f6\u5305\u542b\u8868\u5355\u548c\u67e5\u8be2\u7ed3\u679c\u663e\u793a\u6846\uff0c\u8868\u5355\u4e0d\u65ad\u590d\u7528\u3002<\/li>\n<\/ol>\n<ol>\n<li>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.<\/li>\n<li>Learn something about CSS\u00a0and use it to beatify the checker&#8217;s page.<\/li>\n<li>Learn something about Jquery,\u00a0ajax or else. The codes can refresh\u00a0the checker index page without jumping into others. Which means, the index contain the html form and the result d<span id=\"ouHighlight__0_1TO0_6\" class=\"\">isplay<\/span><span id=\"noHighlight_0.5326241997536272\">\u00a0on same page, visitor can reuse the form and read the result on same page,\u00a0without clicking &#8220;Back to index and check again&#8221;.<\/span><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u671f\u89c4\u5212\u65e5\u5fd7 Previous\u00a0Development Plan \uff1a &gt;10\/02\/2016&lt; &#038; &hellip; <a href=\"http:\/\/goyuwei.com\/blog\/?p=345\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">17\/03\/2016 \u2013 Tolerance Checker Development Log\u2013 \u6781\u9650\u504f\u5dee\u67e5\u8be2\u5668\u5f00\u53d1\u65e5\u5fd7<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[5,21,9,3],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-aside","hentry","category-info-tech-","category-lab-log-","category-mechanical-engineering-","category-site-construction-","post_format-post-format-aside"],"_links":{"self":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":0,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"wp:attachment":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}