Import Data into Tally
Import Data into Tally
getActiveSheet();
// Get the highest row number and column letter
$highestRow = $worksheet->getHighestDataRow();
$highestColumn = $worksheet->getHighestDataColumn();
// Convert the column letter to a number
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
// Initialize the XML data
$xml_data = ‘
1
Import
Data
All Masters
##SVCOMPANYCONNECTNAME
‘;
// Loop through the rows and generate the XML data
for ($row = 2; $row <= $highestRow; $row++) {
$ledgerName = $worksheet->getCellByColumnAndRow(0, $row)->getValue();
$groupName = $worksheet->getCellByColumnAndRow(1, $row)->getValue();
$xml_data .= ‘
‘.$ledgerName.’
‘.$groupName.’
‘;
}
// Close the XML data
$xml_data .= ‘
‘;
// Generate the XML file and save it
$xml_file = ‘import_data.xml’;
file_put_contents($xml_file, $xml_data);
// Display success message
echo ‘
Data imported successfully!
‘;
}
?>