使用Java合并Excel文件中的单元格

时间:2019-03-12 12:06:01

标签: java excel merge apache-poi cell

我正在使用Apache Poi合并Excel文件中的多个标头。在我的excel文件中,我需要合并多个标题。我可以合并signle标头,但由于需要多次,因此必须对其进行迭代。

当我尝试使用addMergedRegion合并列时,出现了相交错误。谁能帮我这个。我想通过合并在cellsToMerge列表中给定的大小在第一行写标题。

if (in_array($filter, ['forward', 'midfielders', 'defenders', 'goalkeepers'])) {
    $this->db->where('position', ucfirst(rtrim($filter, 's')));
}

if (in_array($filter, ['highest_price', 'lowest_price'])) {
    $tmp = $this->external_api_model->get_filtered_football_pairs($limit, $start, $filter);
    $players = json_decode($tmp, true);
    $this->db->where_in('symbol', $players);
    foreach ($players as &$p) {
        $p = "'" . $this->db->escape_str($p) . "'";
    }
    $this->db->order_by("IF(FIELD(symbol," . implode(",", $players) . ")=0,1,0),
                         FIELD(symbol," . implode(",", $players) . ")");
} else {
    $this->db->limit($limit, $start);
}

if ($player != '') {
    $this->db->like('tblmarkets_football.name', $player);
}

0 个答案:

没有答案