class Csv extends BaseWriter (View source)

Properties

protected bool $includeCharts Write charts that are defined in the workbook? Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object;. from BaseWriter
protected bool $preCalculateFormulas Pre-calculate formulas Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file. from BaseWriter

Methods

bool
getIncludeCharts()

Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.

setIncludeCharts(bool $pValue)

Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.

bool
getPreCalculateFormulas()

Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.

setPreCalculateFormulas(bool $pValue)

Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save.

bool
getUseDiskCaching()

Get use disk caching where possible?

setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

string
getDiskCachingDirectory()

Get disk caching directory.

__construct(Spreadsheet $spreadsheet)

Create a new CSV.

save(string $pFilename)

Save PhpSpreadsheet to file.

string
getDelimiter()

Get delimiter.

CSV
setDelimiter(string $pValue)

Set delimiter.

string
getEnclosure()

Get enclosure.

CSV
setEnclosure(string $pValue)

Set enclosure.

string
getLineEnding()

Get line ending.

CSV
setLineEnding(string $pValue)

Set line ending.

bool
getUseBOM()

Get whether BOM should be used.

CSV
setUseBOM(bool $pValue)

Set whether BOM should be used.

bool
getIncludeSeparatorLine()

Get whether a separator line should be included.

CSV
setIncludeSeparatorLine(bool $pValue)

Set whether a separator line should be included as the first line of the file.

bool
getExcelCompatibility()

Get whether the file should be saved with full Excel Compatibility.

CSV
setExcelCompatibility(bool $pValue)

Set whether the file should be saved with full Excel Compatibility.

int
getSheetIndex()

Get sheet index.

CSV
setSheetIndex(int $pValue)

Set sheet index.

Details

bool getIncludeCharts()

Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.

If false (the default) it will ignore any charts defined in the PhpSpreadsheet object.

Return Value

bool

IWriter setIncludeCharts(bool $pValue)

Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.

Set to false (the default) to ignore charts.

Parameters

bool $pValue

Return Value

IWriter

bool getPreCalculateFormulas()

Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.

Return Value

bool

IWriter setPreCalculateFormulas(bool $pValue)

Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save.

Parameters

bool $pValue Pre-Calculate Formulas?

Return Value

IWriter

bool getUseDiskCaching()

Get use disk caching where possible?

Return Value

bool

IWriter setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

Parameters

bool $pValue
string $pDirectory Disk caching directory

Return Value

IWriter

Exceptions

Exception when directory does not exist

string getDiskCachingDirectory()

Get disk caching directory.

Return Value

string

__construct(Spreadsheet $spreadsheet)

Create a new CSV.

Parameters

Spreadsheet $spreadsheet

save(string $pFilename)

Save PhpSpreadsheet to file.

Parameters

string $pFilename Name of the file to save

Exceptions

Exception

string getDelimiter()

Get delimiter.

Return Value

string

CSV setDelimiter(string $pValue)

Set delimiter.

Parameters

string $pValue Delimiter, defaults to ','

Return Value

CSV

string getEnclosure()

Get enclosure.

Return Value

string

CSV setEnclosure(string $pValue)

Set enclosure.

Parameters

string $pValue Enclosure, defaults to "

Return Value

CSV

string getLineEnding()

Get line ending.

Return Value

string

CSV setLineEnding(string $pValue)

Set line ending.

Parameters

string $pValue Line ending, defaults to OS line ending (PHP_EOL)

Return Value

CSV

bool getUseBOM()

Get whether BOM should be used.

Return Value

bool

CSV setUseBOM(bool $pValue)

Set whether BOM should be used.

Parameters

bool $pValue Use UTF-8 byte-order mark? Defaults to false

Return Value

CSV

bool getIncludeSeparatorLine()

Get whether a separator line should be included.

Return Value

bool

CSV setIncludeSeparatorLine(bool $pValue)

Set whether a separator line should be included as the first line of the file.

Parameters

bool $pValue Use separator line? Defaults to false

Return Value

CSV

bool getExcelCompatibility()

Get whether the file should be saved with full Excel Compatibility.

Return Value

bool

CSV setExcelCompatibility(bool $pValue)

Set whether the file should be saved with full Excel Compatibility.

Parameters

bool $pValue Set the file to be written as a fully Excel compatible csv file Note that this overrides other settings such as useBOM, enclosure and delimiter

Return Value

CSV

int getSheetIndex()

Get sheet index.

Return Value

int

CSV setSheetIndex(int $pValue)

Set sheet index.

Parameters

int $pValue Sheet index

Return Value

CSV