i want to open my report in excel with the coding in class. but the excel is opening but data in excel not come. the debugger is opening...

i want to open my report in excel with the coding in class. but the excel is opening but data in excel not come. the debugger is opening…

what to code in class…

i am coding such as----

server static boolean TransferSummaryOld(TransDate fromDate = datenull(),
TransDate toDate = datenull(),
str 250 excelTemplateName)
{
#AviFiles
boolean ret = false ;
ACX_SalesTransferRegister _salesTransferRegister;
ACX_DepotTable _depotTable;
InventLocation _inventLocation;
InventTable _inventTable;
Address _addressTable;
InventDim _inventDim;
InventBatch _inventBatch;
Query query;
QueryRun queryRun;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;

SysExcelApplication _Application;
SysExcelWorkBooks _Workbooks;
SysExcelWorkBook _Workbook;
SysExcelWorksheets _Worksheets;
sysExcelWorksheet _Worksheet;
SysExcelCells _Cells;
SysExcelCell _Cell;
SysExcelFormatCondition _formatCondition;
SysOperationProgress progress = new SysOperationProgress() ;
int _intRow, x ;
int64 totalRecords ;
str 1024 sourceFileName, targetFileName ;

select count(RecId) from _salesTransferRegister
where _salesTransferRegister.PostingDate >= fromDate
&& _salesTransferRegister.PostingDate <= toDate
&& _salesTransferRegister.DocumentType == Acx_SalesRegDocType::TransferShpt ;
totalRecords = _salesTransferRegister.RecId ;

progress.reset();
progress.setCaption(“Exporting Transfer Summary”);
progress.setAnimation(#AviUpdate);
progress.setTotal(totalRecords);

sourceFileName = CompanyInfo::find().ACX_ExcelReportPath + excelTemplateName ;
targetFileName = ACX_UserSetup::find(curUserId()).ACX_ExcelFilePath + curUserId() + excelTemplateName ;
WinAPI::copyFile(sourceFileName, targetFileName, true) ;

_Application = SysExcelApplication::construct();
_Workbooks =_Application.workbooks(); //gets the workbook object
_Workbooks.open(targetFileName) ;
_Workbook = _Workbooks.item(1);
_Worksheets = _Workbook.worksheets(); //gets the worksheets object
_Worksheet = _Worksheets.itemFromName(‘MainData’); //Selects the first worksheet in the workbook to insert data

//_Worksheet.columns().autoFit() ;
_Cells = _Worksheet.cells();

_intRow = 1 ;

query = new Query();
queryBuildDataSource = query.addDataSource(TableNum(ACX_SalesTransferRegister));

queryBuildDataSource.addRange(fieldNum(ACX_SalesTransferRegister, DocumentType)).value(‘TransferShpt’);
queryBuildDataSource.addRange(fieldNum(ACX_SalesTransferRegister, PostingDate)).value(QueryRange(fromDate , toDate));
//queryBuildDataSource.sortDirection(50017 , SortOrder::Ascending);
//queryBuildDataSource.addSortIndex(fieldNum(ACX_SalesTransferRegister, PostingDate));
queryRun = new queryRun(query);
while (queryRun.next())
{
x++ ;
progress.setCount(x, 1);
_salesTransferRegister = queryRun.get(TableNum(ACX_SalesTransferRegister));

if (fromDate || toDate)
{
_intRow ++ ;
_Cell = _Cells.item(_intRow, 1);
_Cell.value(Date2Str(_salesTransferRegister.PostingDate,123,2,-1,2,-1,2)); // posting Date

_Cell = _Cells.item(_intRow, 2);
_Cell.value(_salesTransferRegister.SourceDocumentNum); // source document number

_Cell = _Cells.item(_intRow, 3);
_Cell.value(_salesTransferRegister.SourceName); // Source Name

_Cell = _Cells.item(_intRow, 4);
_Cell.value(_salesTransferRegister.SourceStreet); // street Address

_Cell = _Cells.item(_intRow, 5);
_Cell.value(_salesTransferRegister.TINNo); // Tin No

_Cell = _Cells.item(_intRow, 6);
_Cell.value(_salesTransferRegister.TransporterVendorName); // Transporter Name

_Cell = _Cells.item(_intRow, 7);
_Cell.value(_salesTransferRegister.BiltyNo); // Bilty Num

_Cell = _Cells.item(_intRow, 8);
_Cell.value(_salesTransferRegister.OutwardLocationCode); // Outward Location Code

select Name from _depotTable
Join _inventLocation
where _depotTable.DepotId == _inventLocation.ACX_DepotId
&& _inventLocation.InventLocationId == _salesTransferRegister.OutwardLocationCode;
_Cell = _Cells.item(_intRow, 9);
_Cell.value(_depotTable.Name); // Depot

select Name from _addressTable
where _addressTable.AddrRecId == _inventLocation.RecId
&& _inventLocation.InventLocationId == _salesTransferRegister.OutwardLocationCode;
_Cell = _Cells.item(_intRow, 10);
_Cell.value(_addressTable.Name); // Location Name

_Cell = _Cells.item(_intRow, 11);
_Cell.value(_salesTransferRegister.ACX_SalePurchType); // Type

_Cell = _Cells.item(_intRow, 12);
_Cell.value(’’); // Batch Type

select * from _inventTable
where _inventTable.ItemId == _salesTransferRegister.ItemId;

_Cell = _Cells.item(_intRow, 13);
_Cell.value(_inventTable.ACX_ChemicalType); // Chemical Type

_Cell = _Cells.item(_intRow, 14);
_Cell.value(_salesTransferRegister.ItemName); // Item Name

/** select * from _inventTable
where _inventTable.ItemId == _salesTransferRegister.ItemId ;**/
_Cell = _Cells.item(_intRow, 15);
_Cell.value(_inventTable.ACX_ItemPrintName); // Item Print Name

_Cell = _Cells.item(_intRow, 16);
_Cell.value(_inventTable.ACX_TechnicalName); // Technical Name

_Cell = _Cells.item(_intRow, 17);
_Cell.value(_inventTable.Acx_PackingSize); // Packing size

_Cell = _Cells.item(_intRow, 18);
_Cell.value(_salesTransferRegister.Quantity); // Quantity

_Cell = _Cells.item(_intRow, 19);
_Cell.value(_salesTransferRegister.UnitPrice); // Unit Price

_Cell = _Cells.item(_intRow, 20);
_Cell.value(_salesTransferRegister.LineAmount); // Line Amount

_Cell = _Cells.item(_intRow, 21);
_Cell.value(’’); // Sales Tax Amount

_Cell = _Cells.item(_intRow, 22);
_Cell.value(_salesTransferRegister.TaxBaseAmount); // Tax Base Amount

select inventBatchId from _inventDim
where _inventDim.inventDimId == _salesTransferRegister.InventDimID ;
_Cell = _Cells.item(_intRow, 23);
_Cell.value(_inventDim.inventBatchId); // Batch Id

select prodDate,expDate from _inventBatch
where _inventBatch.inventBatchId == _inventDim.inventBatchId;
_Cell = _Cells.item(_intRow, 24);
_Cell.value(_inventBatch.prodDate); // Manufacturing Date
_Cell = _Cells.item(_intRow, 25);
_Cell.value(_inventBatch.expDate); // Expiry Date

_Cell = _Cells.item(_intRow, 26);
_Cell.value(_salesTransferRegister.FormCode); // Form

_Cell = _Cells.item(_intRow, 27);
_Cell.value(_salesTransferRegister.ACX_ItemCategory); // Item Category

_Cell = _Cells.item(_intRow, 28);
_Cell.value(_salesTransferRegister.BEDAmount); // BED Amount

_Cell = _Cells.item(_intRow, 29);
_Cell.value(_salesTransferRegister.ECessAmount); // ECess Amount

_Cell = _Cells.item(_intRow, 30);
_Cell.value(_salesTransferRegister.SHECessAmount); // SHECess Amount

_Cell = _Cells.item(_intRow, 31);
_Cell.value(_salesTransferRegister.SAEDAmount); // SAED Amount

_Cell = _Cells.item(_intRow, 32);
_Cell.value(_salesTransferRegister.TotalAmount); // Total Amount

/** select ACX_ChemicalSubtype from _inventTable
where _inventTable.ItemId == _salesTransferRegister.ItemId;**/
_Cell = _Cells.item(_intRow, 33);
_Cell.value(_inventTable.ACX_ChemicalSubtype); // Chemical Sub Type

_Cell = _Cells.item(_intRow, 34);
_Cell.value(_salesTransferRegister.ACX_ItemAppearance); // Item Appearance

_Cell = _Cells.item(_intRow, 35);
_Cell.value(_salesTransferRegister.ACX_Cases); // Cases

_Cell = _Cells.item(_intRow, 36);
_Cell.value(_salesTransferRegister.ExciseTariffCode_IN); // Excise Tariff Code

_Cell = _Cells.item(_intRow, 37);
_Cell.value(_salesTransferRegister.BiltyDate); // Bilty Date

_Cell = _Cells.item(_intRow, 38);
_Cell.value(_salesTransferRegister.Month); // Month
}
progress.update(true);
}

info(‘Exported to Excel’);

CodeAccessPErmission::revertAssert() ;
_Application.visible(true); // opens the excel worksheet

/**workbook.saveAs(fileName);

workbook.comObject().save();

workbook.saved(true);**/

return ret ;
}

Please anybody help me…

Regards

Vijay