Hi lads,
I have done plenty of reading this morning but I am at a loss about what my issue is here.
Stripped it right down:
- Form Code is just a button.
- On Submit Code After is:
My table jos_chronoforms_RACIRoles has just three columns: Resource, ResourceName, ResourceGroup.
This is what is generated in Excel (see attached). I can generate CSVs without any problems.
Any ideas? Using ChronoContact 3.1 RC5.5.
Cheers,
Brian.
I have done plenty of reading this morning but I am at a loss about what my issue is here.
Stripped it right down:
- Form Code is just a button.
- On Submit Code After is:
<?php
global $mainframe;
$database =& JFactory::getDBO();
include_once JPATH_BASE.DS.'/administrator/components/com_chronocontact/excelwriter/'."Writer.php";
//echo $_POST['formid'];
//$formid = JRequest::getVar( 'formid', array(), 'post', 'array');
$database->setQuery( "SELECT Resource, ResourceName, ResourceGroup FROM jos_chronoforms_RACIRoles" );
$formname = "anyform";//$database->loadResult();
$tablename = "jos_chronoforms_RACIRoles";
$tables = array( $tablename );
$result = $database->getTableFields( $tables );
$table_fields = array_keys($result[$tablename]);
$database->setQuery( "SELECT Resource, ResourceName, ResourceGroup FROM ".$tablename."" );
$datarows = $database->loadObjectList();
$xls =& new Spreadsheet_Excel_Writer();
$xls->setVersion(8); // this fixes the 255 limit issue!🙂
$xls->send("ChronoForms - ".$formname." - ".date("j_n_Y").".xls");
$format =& $xls->addFormat();
$format->setBold();
$format->setColor("blue");
if (strlen($formname) > 10){$formname = substr($formname,0,10);};
$sheet =& $xls->addWorksheet($formname.' at '.date("m-d-Y"));
$sheet->setInputEncoding('utf-8');
$titcol = 0;
foreach($table_fields as $table_field){
$sheet->writeString(0, $titcol, $table_field, $format);
$titcol++;
}
$datacol = 0;
$rowcount = 1;
foreach($datarows as $datarow){
foreach($table_fields as $table_field){
$sheet->writeString($rowcount, $datacol, $datarow->$table_field, 0);
$datacol++;
}
$datacol = 0;
$rowcount++;
}
$xls->close();
exit;
?>
My table jos_chronoforms_RACIRoles has just three columns: Resource, ResourceName, ResourceGroup.
This is what is generated in Excel (see attached). I can generate CSVs without any problems.
Any ideas? Using ChronoContact 3.1 RC5.5.
Cheers,
Brian.