PHP reads the values of merged cells in Excel

Source: Internet
Author: User
Rt
In doing a thing, you need to read the contents of the individual columns in Excel, the previous PHP Excelreader, but the merged cells are empty values, and my Excel is not good to judge as long as it is empty with the value of the previous array of the method, the Excel itself is more complex not too good to make changes, Is there any other class or method that can solve this problem?


Reply to discussion (solution)

Try this http://www.oschina.net/code/snippet_76782_1264.

That looks like I saw it. It is the operation of the cell merge when writing, it looks like the next assignment is to the merged cell write value, although not directly solve the problem, but I think if I can write, certainly corresponding should be able to read, I see if I can judge is the merged cell, and so on, first thank you ...

Can't read it directly ...
Finally can only use VBA to write the macro to separate the merged cells, and the values are restored, and then read in PHP ...

Think of a method: You can judge the value of the current cell to handle the line!
Find the empty value of the cell if it is a merged cell, the value is the value of the above or several columns. For example:
for ($i = 1; $i <= $data->sheets[0][' numrows '); $i + +) {
for ($j = 1; $j <= $data->sheets[0][' numcols '); $j + +) {
if (Trim ($data->sheets[0][' cells ' [$i] [$j]) = = "") {//is a merged cell with an empty value, more needs to be judged
for ($k = $i-1; $k >=0; $k-) {
if (Trim ($data->sheets[0][' cells ' [$k] [$j])! = "") {
$data->sheets[0][' cells ' [$i] [$j] = $data->sheets[0][' cells ' [$k] [$j];
Break
}
}
This can be further processed!
}
echo "\" ". $data->sheets[0][' cells ' [$i] [$j]." \",";
}
echo "
";
}

  • Related Article

    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.