1
我試圖上傳一個包含財務數據的Excel表格。它在列A上有帳號,當我上傳表單COL時,數據附帶「x000D」。當我谷歌這說它與隱藏的換行符單元格。有人知道如何從細胞中移除這些換行符嗎?由於PHPEXCEL-如何從單元格中刪除隱藏的換行符
function import_data($filename, &$new_chart_accounts, $extension = '') {
$this->init_worksheet($filename, $extension);
$entries = array();
$new_chart_accounts = array();
$chart_accounts = ChartAccounts::read_all(true);
$cha_description;
$indent = $this->dimension[0][0];
for ($row = $this->dimension[0][1] + 1; $row < $this->dimension[1][1]; $row++) {
$entry = array();
for ($col = $this->dimension[0][0]; $col <= $this->dimension[1][0]; $col++) {
if ($this->sheet->cellExistsByColumnAndRow($col, $row)) {
$cell = $this->sheet->getCellByColumnAndRow($col, $row);
$style = $this->sheet->getStyle($cell->getCoordinate());
$fill = $style->getFill();
if ($fill->getFillType() == PHPExcel_Style_Fill::FILL_NONE
|| ($fill->getFillType() == PHPExcel_Style_Fill::FILL_SOLID && $fill->getStartColor()->getRGB() == 'FFFFFF')) {
$value = trim($cell->getValue());
//print $value;
switch ($col) {
case self::ACCOUNT_NUMBER:
$entry['cha_number'] = $value;
break;
case self::ACCOUNT_DESCRIPTION:
$entry['cha_description'] = $value;
break;
case self::AMOUNT:
case self::AMOUNT_2:
$value = str_replace(array(',', '$'), '', $value);
// $sign = substr($value, strlen($value) - 2, 2);
// if ($sign == 'cr' || $sign == 'dr') {
// $value = str_replace($sign, '', $value);
// } else {
// $sign = 'dr';
// }
// $entry['sign'] = $sign;
// if ($value != '' && is_numeric($value)) {
// $entry['data_amount'] = $value;
// }
$entry['data_amount'] = $value;
}
}
}
}
是否有必要刪除換行符?或者我們可以將其格式化爲一個? – mmr
@ mmr,看到這個文件是從MyOB導入的,當我上傳它時,所有的賬號都帶有「x000D」ex-「1004x00D」。 –
生成此列的列的類型/格式是什麼? – mmr