Skip to content

Negative number in excel format as text. Magento 2

How to make a negative number in excel as a number.
Here is my code

    MagentoFrameworkAppResponseHttpFileFactory $fileFactory,

  $content[] = [
        'qty' => __("QTY"),
        'part_number' => __("PART NUMBER"),
        'invoice' => __("INVOICE #"),
        'date' => __("DATE"),
        'description' => __("Description"),
        'retail' => __("RETAIL"),
        'd_discount' => __("DEALER DISCOUNT"),
        'a_discount' => __("ADDITIONAL DISCOUNT"),
        'total' => __("TOTAL"),
    ];

    $dir = "pub/media/invoices/";
    $fileName = "PurchaseHistoryInvoice_" . date('Ymd_His') . ".xls";

    $content[] = [
                    $qty, $part_number, $inv_number, $inv_date, $description,
                    $retail, $discount, $discountAdditional,$net];
    $convert = new MagentoFrameworkConvertExcel(new ArrayIterator($content));
    $content = $convert->convert('single_sheet');
    
    return $this->fileFactory->create($fileName, $content);

RESULT:

enter image description here