如何通过php访问.xlsb文件? [英] How to access an .xlsb file by php?

查看:32
本文介绍了如何通过php访问.xlsb文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要访问一个.xlsb文件,该文件具有与访问.csv文件的以下代码相同的功能:

I need to access an .xlsb file that does the same function as this code that accesses a .csv file:

<?php
$file1 = __DIR__ . '/download/Trabalhos.csv';
$csv1 = file($file1);
foreach ($csv1 as $row1 => $line1) {
    $row1++;
    $column1 = str_getcsv($line1, ';');
    if ($row1 == 2) {
        $column1[6]."<br>";
        $valor1 = $column1[6];
    }
}

$file2 = __DIR__ . '/download/produtividade do trabalho.csv';
$csv2 = file($file2);
foreach ($csv2 as $row2 => $line2) {
    $row2++;
    $column2 = str_getcsv($line2, ';');
    if ($row2 == 3) {
        $column2[9]."<br>";
        $valor2 = $column2[9];
    }
}
$file3 = __DIR__ . '/download/inatividade do trabalho.csv';
$csv3 = file($file3);
foreach ($csv3 as $row3 => $line3) {
    $row3++;
    $column3 = str_getcsv($line3, ';');
    if ($row3 == 2) {
        $column3[0]."<br>";
        $valor3 = $column3[0];
    }
}

$total = $valor1 * $valor2 * $valor3;

?>

访问.xlsb文件,滚动浏览各列和各行,然后在屏幕上显示行值.

Access the .xlsb file, scroll through the columns and rows, and display the row value on the screen.

示例:第2行,G列(在这种情况下,G = 6)
"A = 0
B = 1
C = 2)"
...

Example: "Line 2, Column G(In this case, G = 6)
"A = 0
B = 1
C = 2)"
...

我希望它向我显示G(6)列中第2行的值.

I want it to show me the value of row 2 that is in column G(6).

与第一个条件相同...

As in the first if ...

if ($row1 == 2) {
        $column1[6]."<br>";
        $valor1 = $column1[6];
    }

推荐答案

您可以使用 PHP来自 EasyXLS 的Excel库.

You can use the PHP Excel library from EasyXLS.

$xls = new COM("EasyXLS.ExcelDocument");
$rows = $xls->easy_ReadXLSBActiveSheet_AsList("Trabalhos.xlsb");
for ($row1=0; $row1<$rows->size(); $row1++)
{
    $rowLine = $rows->elementAt($row1);
        if ($row1 == 2) {
            $column1[6]."<br>";
            $valor1 = $row->elementAt(6);
        }
}

您可以找到更多有关导入的代码示例来自xlsb文件的数据.

这篇关于如何通过php访问.xlsb文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆