• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

Changing code to export print data.

Okay,

To start I understand barely anything regarding delphi.  I have some experience programming in
C++ and of course html so I can understand what parts do what.  What I need to be able to do
is setup an export button to export the same data that the print button prints.

The following code is currenlty being used:


procedure TfrmJobListing.sbtprintClick(Sender: TObject);
begin
  if tnbJobMast.ActivePage='Job List' then
    ppReport2.Print;
  if tnbJobMast.ActivePage='Job Cost' then
    ppReport1.Print;

end;

This code above is used to print certain data to a "print screen".
This data above is the data that I need to be able to export.



procedure TfrmJobListing.sbtexportClick(Sender: TObject);
begin
  try
    if tnbJobMast.ActivePage='Job List' then
    begin
       dgrJob.ExportOptions.FileName:=dm.tblUsers.fieldbyname('exp_path').AsString+'\JobList.xls';
       dgrJob.ExportOptions.Save;

    end;
    if tnbJobMast.ActivePage='Job Cost' then
    begin
       dgrJobCost.ExportOptions.FileName:= dm.tblUsers.fieldbyname('exp_path').AsString+'\JobCost.xls';
      dgrJobCost.ExportOptions.Save;
    end;
  except
    begin
    {}
    end
  end;
end;


This code above currently exports the data in the main table to an excel spreadsheet.  I do not need the data
in the table but rather the same data that the print code generates.

I have tried replacing the dgrJobCost with the ppReport1 with nothing but errors.  I figure for some delphi
guru out there this will be a breeze.


I appreciate the help,


steve
0
c230kochi
Asked:
c230kochi
  • 4
  • 4
1 Solution
 
mikelittlewoodCommented:
Is ppReport some thrid party reporting component you are using to display data?
How are you passing the data you want to display to the reports?
0
 
c230kochiAuthor Commented:
I have no idea, I didn't originally write this code.  The last administrator developed all of their
programs using delphi, when I replaced him they assumed that all network admins new how
to program in delphi (that was a good chuckle).  I couldn't find much info on the ppReport
function other than its type being TppReport, and these procedures.  I don't understand the
code enough to know how ppReport generates its data.  

procedure ppReport2PreviewFormCreate(Sender: TObject);

procedure ppReport1PreviewFormCreate(Sender: TObject);

procedure TfrmJobListing.ppReport2PreviewFormCreate(Sender: TObject);
begin
  ppReport2.PreviewForm.WindowState := wsMaximized;
end;

thanks
0
 
mikelittlewoodCommented:
>> when I replaced him they assumed that all network admins new how to program in delphi<<
Best line Ive heard in ages c230kochi. Has it just been dumped in your lap then?

It sounds like this is a third party component to me for the reporting purposes.
It might be an idea to find out where the data is getting passed from to the report.
Maybe there is a query result set being passed to the report that we can tap into.

Is there any code within the report unit under the OnCreate, OnShow, OnActivate that might start our search off for your dataset?

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mikelittlewoodCommented:
This dgrJobCost, can you find out where it is declared, and what type it is declared as.
Im guessing the ExportOptions.Save has some code behind it to possibly detect what file type you are trying to save to, in your case excel, and perform the specific task. Maybe this component only saves to excel and nothing else.
0
 
c230kochiAuthor Commented:
Yeah its all been pretty much dumped in my lap, this is one of about 4 things they want changed/added.
I love this field, you say, "I'm microsoft and cisco certified, I have experience with wan/lan technologies
in microsoft environments including exchange, and I specialize in security."  They hear I do stuff with
computers and I know how to fix them and anything else that has to do with a computer, which includes
but isn't limited too, custom software, programming, unix, linux, macintosh, and whatever else comes up.
LOL, but oh well I like my job, I just have to learn delphi.  BTW, any suggestions on where I can take
QUALITY courses on delphi programming.  Seeing as I will be here for the next 5 years or so, I should
probably learn it.

okay, to the problem at hand.  The ppreport is a third party program called ReportBuilder.  Looking through ReportBuilder
I could not find a "save as" or "export" feature, it would only let me manipulate the table
designs.

Below is some more code, don't know if its useful.

  object ppReport2: TppReport
    AutoStop = False
    DataPipeline = ppBDEPipeline2
    PrinterSetup.BinName = 'Default'
    PrinterSetup.DocumentName = 'Report1'
    PrinterSetup.Orientation = poLandscape
    PrinterSetup.PaperName = 'Letter (8 1/2" x 11")'
    PrinterSetup.PrinterName = 'Default'
    PrinterSetup.mmMarginBottom = 6350
    PrinterSetup.mmMarginLeft = 6350
    PrinterSetup.mmMarginRight = 6350
    PrinterSetup.mmMarginTop = 6350
    PrinterSetup.mmPaperHeight = 215900
    PrinterSetup.mmPaperWidth = 279401
    PrinterSetup.PaperSize = 1
    DeviceType = 'Screen'
    OnPreviewFormCreate = ppReport2PreviewFormCreate
    TextFileName = 'c:\joblist.xls'
    Left = 143
    Top = 435
    Version = '6.03'
    mmColumnWidth = 0
    DataPipelineName = 'ppBDEPipeline2'
    object ppHeaderBand2: TppHeaderBand
      mmBottomOffset = 0
      mmHeight = 13229
      mmPrintPosition = 0
      object ppLabel12: TppLabel
        UserName = 'Label101'
        Caption = 'Job Status Report'
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlack
        Font.Name = 'Arial'
        Font.Size = 12
        Font.Style = [fsBold, fsUnderline]
        Transparent = True
        mmHeight = 5027
        mmLeft = 82550
        mmTop = 1323
        mmWidth = 36513
        BandType = 0




Something to do with the existing export function


 object tnbJobMast: TTabbedNotebook
    Left = 1
    Top = 70
    Width = 770
    Height = 359
    TabFont.Charset = ANSI_CHARSET
    TabFont.Color = clBtnText
    TabFont.Height = -12
    TabFont.Name = 'Tahoma'
    TabFont.Style = [fsBold]
    TabOrder = 4
    OnChange = tnbJobMastChange
    object TTabPage
      Left = 4
      Top = 24
      Caption = 'Job List'
      object dgrJob: TwwDBGrid
        Left = 1
        Top = 1
        Width = 759
        Height = 325
        Selected.Strings = (
          'jobno'#9'8'#9'Job #'#9'F'
          'job_name'#9'31'#9'Description'#9'F'
          'contr_date'#9'7'#9'Contract Date'#9'F'
          'contr_no'#9'10'#9'Contract #'#9'F'
          'engineer'#9'11'#9'Engineer'#9'F'
          'proj_mangr'#9'2'#9'Mgr'
          'contrt_amt'#9'12'#9'Contract Amt'
          'job_status'#9'1'#9'S'#9'F'
          'job_add1'#9'50'#9'Description'#9'F'
          'customer'#9'80'#9'Customer'#9'F')
        IniAttributes.Delimiter = ';;'
        ExportOptions.ExportType = wwgetHTML
        TitleColor = clBtnFace
        FixedCols = 0
        ShowHorzScrollBar = True
        BiDiMode = bdLeftToRight
        ParentBiDiMode = False
        Ctl3D = True
        Font.Charset = ANSI_CHARSET
        Font.Color = clWindowText
        Font.Height = -12
        Font.Name = 'Tahoma'
        Font.Style = []
        Options = [dgAlwaysShowEditor, dgTitles, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgWordWrap]
        ParentCtl3D = False
        ParentFont = False
        TabOrder = 0
        TitleAlignment = taLeftJustify
        TitleFont.Charset = DEFAULT_CHARSET
        TitleFont.Color = clWindowText
        TitleFont.Height = -11
        TitleFont.Name = 'MS Sans Serif'
        TitleFont.Style = []
        TitleLines = 1
        TitleButtons = False
        UseTFields = False
        PaintOptions.AlternatingRowColor = 8453888
        PaintOptions.ActiveRecordColor = clNavy
      end
0
 
c230kochiAuthor Commented:
dgrJobCost is declared as a TwwDBGrid

It was originally set to save as a .htm file but I wanted excel so the users can alter the cells.
0
 
mikelittlewoodCommented:
the components with ww in the name are call Woll to Woll components widely used through the delphi environment (except for me that is ... dont like databound stuff too much). Some more info on how to use them can be found at http://www.woll2woll.com/
You might even find a tutorial on exporting data here which could be of use.

Ive heard of reportbuilder before but not used or seen it myself. You might get lucky doing a search here on it with some helpful hints.
Its just a bit hard not knowing all the interal methods you might have available to save your report data, or I might be able to suggest something a bit more conclusive for you.

I went on a delphi external course a while back now with a company called Dunstan and Thomas which were pretty good, and they can tailor the courses to your needs/skill level fairly well. Depends how much of the basic concepts you already know from your other programming.
Also with the .NET architecture now out, you will have to decide whether you need to look into this as well unless you can do that through another language.

Let me have another think tonight on the subject and maybe I can find some more information for you.
Im sure others here have used these components before, and hopefully they might spot this question and leave some more useful advice than mine.
0
 
c230kochiAuthor Commented:
I since have solved this issue.

Please close.

ty
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now