report 50015 /Send sample/
{
ApplicationArea = All;
Caption = 'Send sample';
UsageCategory = Tasks;
ProcessingOnly = true;
UseRequestPage = true;
requestpage
{
layout
{
area(content)
{
group(GroupName)
{
}
}
}
actions
{
area(processing)
{
}
}
}
trigger OnInitReport()
begin
end;
trigger OnPreReport()
begin
end;
trigger OnPostReport()
begin
MakeHeader();
MakeBody();
MakeExcelSheet();
// CreateExcelbook();
// if /Usage Statistics Setup/./Mail Recipients/ = '' then
// CurrReport.Quit();
// CollectUniqueTableName();
end;
local procedure MakeHeader()
begin
Rec_ExcelBuffer.Reset();
Rec_ExcelBuffer.DeleteAll();
// Rec_ExcelBuffer.NewRow();
if Rec_UsageStatistics.FindFirst() then begin
Rec_ExcelBuffer.AddColumn('Table Name', false, '', true, false, false, '', Rec_ExcelBuffer./Cell Type/::Text);
if Rec_UsageStatistics.FindSet() then
repeat
Rec_UsageStatistics.SetRange(/Table No./);
if not ListOfDate.Contains(Rec_UsageStatistics./Recorded Date/) then
ListOfDate.Add(Rec_UsageStatistics./Recorded Date/);
until Rec_UsageStatistics.Next() = 0;
foreach Date_D in ListOfDate do begin
Rec_ExcelBuffer.AddColumn(StrSubstNo('%1 (%2)', Rec_UsageStatistics.FieldCaption(/Recorded Date/), Date_D), false, '', false, false, false, '', Rec_excelbuffer./Cell Type/::Number);
end;
// Rec_ExcelBuffer.AddColumn(StrSubstNo('%1 (%2)', Rec_UsageStatistics.FieldCaption(/Recorded Date/), ListOfDate), false, '', false, false, false, '', Rec_excelbuffer./Cell Type/::Number);
end;
// Rec_ExcelBuffer.NewRow();
// if Rec_UsageStatistics.FindSet() then
// repeat
// Rec_UsageStatistics.SetRange(/Table No./);
// if not ListOfCount.Contains(Rec_UsageStatistics./Record Count/) then
// ListOfCount.Add(Rec_UsageStatistics./Record Count/);
// until Rec_UsageStatistics.Next() = 0;
// foreach Count_R in ListOfCount do begin
// Rec_ExcelBuffer.AddColumn((Count_R), false, '', false, false, false, '', Rec_ExcelBuffer./Cell Type/::Text);
// end;
end;
local procedure MakeBody()
begin
Clear(Rec_UsageStatistics);
Rec_UsageStatistics.Reset();
Rec_ExcelBuffer.NewRow();
//table unique values
if Rec_UsageStatistics.FindSet() then
repeat
Rec_UsageStatistics.SetRange(/Table No./);
if Rec_UsageStatistics.FindSet() then
repeat
if not ListOfTableName.Contains(Rec_UsageStatistics./Table Name/) then
ListOfTableName.Add(Rec_UsageStatistics./Table Name/);
until Rec_UsageStatistics.Next() = 0;
foreach TableName in ListOfTableName do begin
Rec_ExcelBuffer.NewRow();
Rec_ExcelBuffer.AddColumn(TableName, false, '', false, false, false, '', Rec_ExcelBuffer./Cell Type/::Text);
end;
//Record count
if Rec_UsageStatistics.FindSet() then
repeat
Rec_UsageStatistics.SetRange(/Entry No./);
if not ListOfCount.Contains(Rec_UsageStatistics./Record Count/) then
ListOfCount.Add(Rec_UsageStatistics./Record Count/);
until Rec_UsageStatistics.Next() = 0;
foreach Count_R in ListOfCount do begin
// Rec_ExcelBuffer.NewRow();
Rec_ExcelBuffer.AddColumn((Count_R), false, '', false, false, false, '', Rec_ExcelBuffer./Cell Type/::Number);
end;
//Record date
// Rec_UsageStatisticsNEW./Table Name/ := Rec_ExcelBuffer./Cell Value as Text/;
until Rec_UsageStatistics.Next() = 0;
// Rec_ExcelBuffer.AddColumn((Rec_UsageStatistics./Record Count/), false, '', false, false, false, '', Rec_ExcelBuffer./Cell Type/::Number);
end;
local procedure MakeExcelSheet()
var
Studentlbl: Label 'raw data';
ExcelFileName: Label 'raw data';
begin
Rec_ExcelBuffer.CreateNewBook(Studentlbl);
Rec_ExcelBuffer.WriteSheet(Studentlbl, CompanyName, UserId);
Rec_ExcelBuffer.SetColumnWidth('A', 25);
Rec_ExcelBuffer.SetColumnWidth('B', 25);
Rec_ExcelBuffer.SetColumnWidth('C', 25);
Rec_ExcelBuffer.SetColumnWidth('D', 25);
Rec_ExcelBuffer.CloseBook();
Rec_ExcelBuffer.SetFriendlyFilename(StrSubstNo(ExcelFileName, CurrentDateTime, UserId));
Rec_ExcelBuffer.OpenExcel();
//Rec_ExcelBuffer.ReadSheet();
end;
var
Rec_ExcelBuffer: Record /Excel Buffer/;
Rec_UsageStatistics: Record /Usage Statistics/;
Rec_UsageStatisticsNEW: Record /Usage Statistics/;
ListOfTableName: List of [Text];
TableName: Text;
ListOfDate: List of [Date];
Count_R: Integer;
ListOfCount: List of [Integer];
Date_D: Date;
}