ePages 6.10 - DE_EPAGES/Core/API/CSV/BaseExportDriver.pm

Package DE_EPAGES::Core::API::CSV::BaseExportDriver

Base class for csv export drivers

Functions

columns
drive
encodeTo
exportCSV
exportLine
fileHandle
fileName
incLineNumber
items
lineNumber
new
parse
popID
pushID
topID
writeHeader
writeLine
writeLines
writer

columns

return the column name array

Syntax
$aColumns = $self->columns;
Return
$aColumns

drive

write the data content lines

Syntax
$self->drive();

encodeTo

returns the target encoding (was setted in exportCSV)

Syntax
encodeTo();
Example
$Driver->encodeTo();
Return
$Encoding (string)
target encoding (utf8,iso-8859-1,...)

exportCSV

exports data (2 dim. array) into a file. starts the document, calls function parse and closes the document

Syntax
$Exporter->exportCSV($FileName, $hFormat, $aColumns, $aaData );
Input
$FileName (string)
export file
$hFormat (ref.hash)
export file format
  • eol - end of line (optional, default: "\n")
  • encoding - character encoding (optional, default: "iso-8859-1")
  • quote_char - field delimiter (optional, default: '"')
  • escape_char - escape character (optional, default: '"')
  • sep_char - field separator (optional, default: ",")
  • open_mode - file open mode (optional, default: ">")
  • usebom - write a byte order mark for unicode files if 'utf8' or
    encoding =~ /^utf/i (optional, default: 1)

$aColumns (ref.array)
column names (used for header)
$aaData (ref.array.array.string)
sheet data

exportLine

exports one data line, get the line element from function topID('Item')

Syntax
$self->exportLine();

fileHandle

return the current fileHandle

Syntax
$self->fileHandle;
Return
$FileHandle (filehandle)
setted by exportCSV

fileName

return the current fileName

Syntax
$self->fileName;
Return
$FileName (string)
export file name

incLineNumber

return the incremented linenumber

Syntax
$linenumber = $self->incLineNumber;
Return
$linenumber

items

return the items to export

Syntax
my $Items = $self->items();
Return
$aaData (ref.array.array.string)
parameter of exportCSV

lineNumber

return the current linenumber

Syntax
$linenumber = $self->lineNumber;
Return
$linenumber

new

create a new csv export driver

Syntax
$Exporter = DE_EPAGES::Core::API::CSV::BaseExportDriver->new(%options);
Input
%options (hash)
exporter options
Return
$Exporter (object)
exporter

parse

calls function writeHeader, calls function drive

Syntax
$self->parse();

popID

removes a parameter from the parameter stack and returns its value.

Syntax
$Value = $self->popID( $Key );
Example
$CompanyID = $self->popID( 'CompanyID' );
Input
$Key (string)
parameter name
Return
(parameter value)
$Value

pushID

adds a parameter to the parameter stack. Any previous parameter with the same name will be hidden until $self->popID( $Key ) is called. Use $self->topID( $Key ) to get the parameter value. Use $self->popID( $Key ) to remove the parameter from the stack.

Syntax
$self->pushID( $Key, $Value );
Example
$self->pushID( 'CompanyID', $CompanyID );
Input
$Key (string)
parameter name
$Value
parameter value

topID

returns the current value of a parameter

Syntax
$Value = $self->topID( $Key );
Example
$CompanyID = $self->topID( 'CompanyID' );
Input
$Key (string)
parameter name
Return
(parameter value)
$Value

writeHeader

writes the header

Syntax
$self->writeHeader();

writeLine

exports a line ( converts and writes to the filehandle )

Syntax
$self->writeLine($aLineElements);

writeLines

writes the content lines each item of $self->items would exported via function exportLine

Syntax
$self->writeLines();

writer

return the current csv writer

Syntax
$Writer = $self->writer;
Return
$Writer