Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Exporting Report to XLS,XLST
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Exporting Report to XLS,XLST

 Post Reply Post Reply
Author
Message
checksandy View Drop Down
Groupie
Groupie


Joined: 17 May 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote checksandy Quote  Post ReplyReply Direct Link To This Post Topic: Exporting Report to XLS,XLST
    Posted: 08 September 2010 at 8:30am

Hi Everybody,

In my application, I am using report control to display textual data in various columns.
Is there a way by which ReportControls Records can be directly saved to Excel format (XLS,XLST) or other ASCII formats (CSV)
 
Thanks
Sandy
Back to Top
SHAN View Drop Down
Groupie
Groupie
Avatar

Joined: 17 July 2010
Location: Dubai
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote SHAN Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2010 at 11:04pm

Hi Sandy,

   You can Export Report Control Data to Excel Using this Code...!
 
 
  
Public Sub ReportControlToExcel(Rptcontrol As ReportControl)
      Dim xlObject    As Excel.Application
 
      Dim xlWB        As Excel.Workbook
            
          Set xlObject = New Excel.Application
 
      
          'This Adds a new woorkbook, you could open the workbook from file also
 
          Set xlWB = xlObject.Workbooks.Add
                  
          Clipboard.Clear 'Clear the Clipboard
          'Add Column Headers
             For i = 1 To Rptcontrol.Columns.count
                   xlObject.ActiveSheet.Cells(1, i).Value = _
                        "" & Rptcontrol.Columns.Column(i - 1).Caption
              Next
             
           'Select All Records
                        For i = 0 To Rptcontrol.Rows.count - 1
                         Rptcontrol.Rows(i).Selected = True
                        Next
             'Copy Records to ClipBoard
                      Rptcontrol.Copy
              With xlObject.ActiveWorkbook.ActiveSheet
 
              .Range("A2").Select 'Select Cell A2 (will paste from here, to different cells)
              .Paste              'Paste clipboard contents
              End With
              'Clear Selected Records from Selection
              Rptcontrol.SelectedRows.DeleteAll
           Clipboard.Clear
                      'Format excel Columns
             For i = 1 To Rptcontrol.Columns.count
            xlObject.ActiveSheet.Columns(i).AutoFit
            xlObject.ActiveSheet.Columns(i).HorizontalAlignment = xlCenter
              Next
              'Format Excel Rows
             xlObject.ActiveSheet.Rows(1).Font.Bold = True
          xlObject.ActiveSheet.Rows(1).Interior.Color = &HFFC0C0
         xlObject.ActiveSheet.Rows(2).Select
         'Freeze the First Row
         xlObject.ActiveWindow.FreezePanes = True
        
          ' This makes Excel visible
          xlObject.Visible = True

End Sub
 
 
-----------------------------------------------------------------------------------
'To call the Method Use
 
call ReportControlToExcel(Reportcontrol1)
   
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows 7 Professional
Language: Visual Basic 6.0
Back to Top
checksandy View Drop Down
Groupie
Groupie


Joined: 17 May 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote checksandy Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2010 at 4:51am
Hi Shan
Thank you for the code snippet. But this code will only work in PCs which have Excel already installed. I was looking for some internal function which can directly write a XLS/XLST file or for that matter a PDF file, Basically an export feature.
Sandy
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2010 at 9:41am
Hi;

take a look at XLSGEN: http://xlsgen.arstdesign.com/
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.