Use PHP to parse execl problem? + Urgent urgent and urgent urgent

Source: Internet
Author: User
PHP parsing execl

My PHP parsing execl I use the Php-excel-reader tool to parse, but I am now the case is this
Problem one: When I read execl, I found that the execl that I read was marked with an asterisk (*), so when I was in the database, it was
There are asterisks, I think the way is to read out the asterisk, with a space instead, but in the database, still no, do not know whether it is me
The alternative position is not written in the wrong place.

Issue two: Focus
The customer gives the execl inside points up and down 2 parts, above is a table of data, the following is another table in the data, so is the next parse here Execl, to the execl above the data corresponding to the corresponding table, the following contents, stored in the corresponding table, that is

EXECL:

Above: The contents of a table

Below: contents of table B

Now the data that is parsed into the execl is stored in the corresponding table.


Reply to discussion (solution)

No one's friends know. Forget pointing

Excel is not parsed with PHP

But if you're in a hurry, and if the number of Excel tables given by the client is limited,

You can use the Navicat software to save the table directly to the database and then use PHP to operate

That's what I did before, bypassing what I don't understand .... Although it is not good for the technical improvement but for the pursuit of results is very effective ...

Another: Navicat import function is very powerful ...

1) You read the Excel data through PHP, remove the table header row of data, then the rest is the actual data, according to determine whether there is a * number, replace can.
2) You can store the contents of the top and bottom tables in two different Excel and read the information separately.

Reply to 3 floor friends, you give the 1th method is right, positive solution, 2nd method, will they divided into 2 execl, this is mainly the customer department agreed, said using software is to simplify the operation, so there is no difference between. I can only think of other ways ... Thank you

Reply to the 2 floor friend, Navicat This is a MySQL development tool, I am to upload the execl to the database, you give this method is not very good. Thank you

The second problem, the best way is a sheet save a table of data, so the import is easier to explain. If you really want to save two tables of data in a sheet, then you can also define the separation conditions (such as two tables in the middle of the empty 2 rows), and then loop through the rows, to determine whether the row is delimited rows, after separating the row is the data of the second table.

Reply to the 6 floor, well, your idea is still good, I think about it, in writing code. Thank you


The effect is this: when looping to 9920000 (Henan subtotal) Here stop, because this data can not be inserted into the database, should be here to terminate, and jump to the next loop. I used a break; , continue; These 2 exit loops are all inserted into the database with a null value. Ask me where to write wrong, I write here is the cycle of "monthly sales plan" This column, when the 9920000 should stop.


if ($month _sales_plan= $data->sheets[0][' cells '][8][2]) {
$month _sales_plan;
echo $month _sales_plan;
Break

}
else{
$month _sales_plan= $data->sheets[0][' cells ' [$i][5];
}

Do not understand your code, suggest: Imported Excel table, must be in the specified format, and this format must be the program can be interpreted, and then in the program to interpret the data you want to.

In fact, my demand is: we can look at the 8 floor of the picture, is the loop when encountered subtotal, total such fields, will skip, continue to loop. Until the end of the cycle.

That neither the code nor the data file is given
I had to do an example.

$PHPExcel = new Phpexcel_reader_excel5 (), $sheet = $PHPExcel->load (' Test1.xls ')->getactivesheet (); $allRow = $ Sheet->gethighestrow (); for ($i =1; $i <= $allRow; $i + +) {  if ($sheet->getcell ("b$i")->getvalue ()! = ")     Echo $sheet->getcell ("b$i")->getvalue (). ' : ' . $sheet->getcell ("c$i")->getvalue (), '
';}
a:4650000
b:2480000
c:2790000
d:8370000
e:2790000
f:26660000

Should be able to see, right?!

11 Floor Brothers, I do not understand, you use what tool phpexecl?? , I use excel_reader2.php this file, phpexecl I just downloaded a 1.7.9 version of, I use my excel_reader2.php no, Now run your code in the phpexecl1.7.9 version, with the effect that, for example, there is no data inside,

11 floor friend, through Echo $sheet->getcell ("b$i")->getvalue () can take out the corresponding value, but with the subtotal, skip what relationship, I do not understand. Forget the point.

West-East gas transmission and sale of natural gas daily table:
Report date: May 27 8 o'clock to May 28 8 O'Clock:
Pin Volume (NM3):
User name:
Monthly Sales Plan 1: Henan province
46500002:
24800003:
2790000 Henan Province Subtotal:
=sum (E5:E7) 1: Anhui Province
83700002:
27900003:
26660000 Anhui Province subtotal:
=sum (E9 : E11) 1: Jiangsu Province

11 Floor brother, I added a sentence in the output of the statement echo $sheet->getcell ("e$i")->getvalue (). "
";

There may be a situation here, that is, the monthly sales plan inside the 4650000,2480000,2790000 these may each execl inside the content is different, so according to $sheet->getcell ("e$i")->getvalue () To take is definitely not accurate, so do well is based on small, or =sum such words to judge, that is, to such words, on the skip, continue to cycle, this I will not, I write the judgment seems to not work.

Effect:
Monthly Sales Plan
4650000
2480000
2790000
=sum (E5:e7)
8370000
2790000
26660000
=sum (E9:E11)
4650000
15500000
8680000
6200000
310000
2790000
3720000
4030000
3100000
4960000
2170000
1550000
2480000
3720000
1550000
=sum (E13:e27)
6200000
6200000
4650000
4650000
1240000
1240000
=sum (E8,e12,e28,e30,e32,e34)

Depending on which column you want to read, it's about your execl file.
I don't see it, I'm not.

No, I don't know how to write this judgment statement.

11 Floor Brothers, you see this execl, how to Let, execl in all small subtotals, in the database, do not save the database,

In order to parse execl appear such execl function, SUM (J9:J11), how to do, how to convert him to the corresponding specific value. Please

When a function such as sum is used in execl, it is resolved as shown in the

A great god of PHP, a solution, I appreciate it.

Put your execl file on the public web and share it.

22 floor friend, I uploaded, url http://download.csdn.net/my

22 Floor friends, I uploaded to my "Resources" inside, you help to look, I do not know why the analytic will be a function. Rather than numbers,

Still no one's answering me.

11 Floor Brothers, you see this execl, how to Let, execl in all small subtotals, in the database, do not save the database,

$data =array ();//Save the Read data
$cols;//column coordinates eg:a,b,c .... Phpexcel has provided methods to obtain
$totalLine;//Total number of rows, phpexcel have provided methods to obtain
$line = 1;
for ($line; $line <= $totalLine; $line + +) {
$row =array ();//row of data
foreach ($cols as $col) {
$coor = $col. $line;//coordinates eg:a1,b1,c1 .....
$value;//The value of the corresponding $coor obtained by the method provided by Phpexcel
if (Preg_match ('/Subtotal/', $value)) {//here to make a judgment,
Break Wrap if you read "Subtotal"
}else{
$row []= $value;
}
}
$data [$line]= $row;
}

Next, save the $data in the database, okay?








Well, thanks, I'm trying.

Such a regular Excel table, how bad read it. If you are afraid of the problem of direct insertion, you can put the loop out of an array of arrays, manually sift out the unnecessary data, avoid logical judgment (when to jump out of the loop). ), and it's almost done soon.

28 Floor friend manual screening?? Not very inside, I will not be read out, in the customer area to filter which storage database, so customers will be uncomfortable.

When reading to a subtotal line skip Ah ... The merger is irregular, do you want to turn into CVS a lot better

· The merger is irregular, do you want to turn into CVS a lot better???? Why did you turn it into CVS? Does it have to go to CVS? I would like to judge that if I read the total, the words will be skipped.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.