How to export sql table data to Excel/PDf using Storedprocedure?

Hi ,
        I have one table in sqlserver2008R2 that named "Customer" so that table hold the 1 Lac rows. Now I want send this table data to Excel/pdf with Columns using Storedprocedure.
   I have tried this using xp_cmdshell so This is not working for me.
finally i want to get data in Excel and pdf also.
Please guide me

You can actually run an Excel Macro to grab the data from the SQL Server DB.  Below are some samples.
Sub ADOExcelSQLServer()
' Carl SQL Server Connection
' FOR THIS CODE TO WORK
' In VBE you need to go Tools References and check Microsoft Active X Data Objects 2.x library
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Server_Name = "Excel-PC\SQLEXPRESS" ' Enter your server name here
Database_Name = "Northwind" ' Enter your database name here
User_ID = "" ' enter your user ID here
Password = "" ' Enter your password here
SQLStr = "SELECT * FROM dbo.Orders" ' Enter your SQL here
Set Cn = New ADODB.Connection
Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
' Dump to spreadsheet
With Worksheets("sheet1").Range("a1:z500") ' Enter your sheet name and range here
.ClearContents
.CopyFromRecordset rs
End With
' Tidy up
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub
Sub ADOExcelSQLServer()
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Server_Name = "LAPTOP\SQL_EXPRESS" ' Enter your server name here
Database_Name = "Northwind" ' Enter your database name here
User_ID = "" ' enter your user ID here
Password = "" ' Enter your password here
SQLStr = "SELECT * FROM Orders" ' Enter your SQL here
Set Cn = New ADODB.Connection
Cn.Open "Driver={SQL Server};Server=" & Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
With Worksheets("Sheet1").Range("A2:Z500")
.ClearContents
.CopyFromRecordset rs
End With
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub
Sub TestMacro()
' Create a connection object.
Dim cnPubs As ADODB.Connection
Set cnPubs = New ADODB.Connection
' Provide the connection string.
Dim strConn As String
'Use the SQL Server OLE DB Provider.
strConn = "PROVIDER=SQLOLEDB;"
'Connect to the Pubs database on the local server.
strConn = strConn & "DATA SOURCE=(local);INITIAL CATALOG=NORTHWIND.MDF;"
'Use an integrated login.
strConn = strConn & " INTEGRATED SECURITY=sspi;"
'Now open the connection.
cnPubs.Open strConn
' Create a recordset object.
Dim rsPubs As ADODB.Recordset
Set rsPubs = New ADODB.Recordset
With rsPubs
' Assign the Connection object.
.ActiveConnection = cnPubs
' Extract the required records.
.Open "SELECT * FROM Categories"
' Copy the records into cell A1 on Sheet1.
Sheet1.Range("A1").CopyFromRecordset rsPubs
' Tidy up
.Close
End With
cnPubs.Close
Set rsPubs = Nothing
Set cnPubs = Nothing
End Sub
Finally, you can run a SProc in SQL Server, from Excel, if you want the SProc to do the export.
Option Explicit
Sub Working2()
'USE [Northwind]
'GO
'DECLARE @return_value int
'EXEC @return_value = [dbo].[TestNewProc]
' @ShipCountry = NULL
'SELECT 'Return Value' = @return_value
'GO
Dim con As Connection
Dim rst As Recordset
Dim strConn As String
Set con = New Connection
strConn = "Provider=SQLOLEDB;"
strConn = strConn & "Data Source=LAPTOP\SQL_EXPRESS;"
strConn = strConn & "Initial Catalog=Northwind;"
strConn = strConn & "Integrated Security=SSPI;"
con.Open strConn
'Put a country name in Cell E1
Set rst = con.Execute("Exec dbo.TestNewProc '" & ActiveSheet.Range("E1").Text & "'")
'The total count of records is returned to Cell A5
ActiveSheet.Range("A5").CopyFromRecordset rst
rst.Close
con.Close
End Sub
Sub Working()
'USE [Northwind]
'GO
'DECLARE @return_value int
'EXEC @return_value = [dbo].[Ten Most Expensive Products]
'SELECT 'Return Value' = @return_value
'GO
Dim con As Connection
Dim rst As Recordset
Set con = New Connection
con.Open "Provider=SQLOLEDB;Data Source=LAPTOP\SQL_EXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;"
Set rst = con.Execute("Exec dbo.[Ten Most Expensive Products]")
'Results of SProc are returned to Cell A1
ActiveSheet.Range("A1").CopyFromRecordset rst
rst.Close
con.Close
End Sub
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Similar Messages

  • RE: How to Export the Table data Into PDF File  in ADF

    Hi Experts,
    I am using Jdeveloper 11.1.2.3.0
    I am created employee VO and Drag and Drop as a Table in a page. So need to Export the Table data into A PDF file.
    So please give me some suggestions regarding this Scnerio.
    With Regards,
    satish

    Hi Guys ,
    Any more answers for this question.
    Please find my jsff below
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core" xmlns:report="http://www.adfwithejb.blogspot.com">
      <af:panelGroupLayout layout="vertical" id="pgl2">
          <af:query id="qryId1" headerText="Service Tariff Mapping Details" disclosed="true"
                    value="#{bindings.findByTarifValidFromQuery.queryDescriptor}"
                    model="#{bindings.findByTarifValidFromQuery.queryModel}"
                    queryListener="#{reportWiseInvoiceBean.genericQueryListener}"
                    queryOperationListener="#{bindings.findByTarifValidFromQuery.processQueryOperation}"
                    resultComponentId="pc1::t2">
         <f:attribute name="queryExpression" value="bindings.findByTarifValidFromQuery.processQuery"/>
                          </af:query>
        <af:panelCollection id="pc1" styleClass="AFStretchWidth">
          <f:facet name="menus"/>
          <f:facet name="toolbar">
              <af:toolbar id="t1">
                 <af:menuBar id="pt_m1">
                <report:reportDeclarative ButtonName="ExportToExcel" ReportName="ServiceTariffMappingDetails"
                                          ReportType="PDF" TableId=":::pc1:t2" id="rd1" Pagination="true"/>
                <af:commandButton text="excel" id="cb1" binding="#{exportToExcelBean.exportID}">
                <af:setActionListener from="pt1:pgl1:pgl2:pc1:t2" to="#{viewScope['exporter.exportedId']}"/>
                <af:setActionListener from="border:1px solid #cccccc" to="#{viewScope['exporter.thStyle']}"/>
                <af:setActionListener from="border:1px solid #cccccc" to="#{viewScope['exporter.tdStyle']}"/>
                <af:fileDownloadActionListener method="#{exportToExcelBean.exportToExcel}" filename="Service TariffMapping.xls"
                                                 contentType="text/excel;chatset=UTF-8;"/>
                </af:commandButton>
                <af:commandMenuItem id="pt_cmi133" icon="/images/common/Excel-icon.png"
                                                shortDesc="ExportToExcel"
                                >
                                <af:exportCollectionActionListener exportedId="t2" type="excelHTML"
                                                                   title="Service Tariff Mapping"
                                                                   filename="Service Tariff Mapping.xls"/>
                            </af:commandMenuItem></af:menuBar>
              </af:toolbar>
          </f:facet>
          <f:facet name="statusbar"/>
          <af:table value="#{bindings.ServiceTariffMappingDtlsRVO1.collectionModel}" var="row"
                    rows="#{bindings.ServiceTariffMappingDtlsRVO1.rangeSize}"
                    emptyText="#{bindings.ServiceTariffMappingDtlsRVO1.viewable ? 'No data to display.' : 'Access Denied.'}"
                    fetchSize="#{bindings.ServiceTariffMappingDtlsRVO1.rangeSize}" rowBandingInterval="0"
                    filterModel="#{bindings.findByTarifValidFromQuery.queryDescriptor}"
                    queryListener="#{bindings.findByTarifValidFromQuery.processQuery}" filterVisible="true" varStatus="vs"
                    id="t2" columnStretching="last" binding="#{ServiceTariffMappBean.testTable}">
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.label}"
                       id="c1">
              <af:inputText value="#{row.bindings.NormalTariffCode.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NormalTariffCode.tooltip}" id="it1">
                <f:validator binding="#{row.bindings.NormalTariffCode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.label}"
                       id="c2">
              <af:inputText value="#{row.bindings.ServiceCode.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceCode.tooltip}" id="it2">
                <f:validator binding="#{row.bindings.ServiceCode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.label}" id="c3">
              <f:facet name="filter">
                <af:inputDate value="#{vs.filterCriteria.TrfVldFrm}" id="id1">
                  <af:convertDateTime pattern="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.format}"/>
                </af:inputDate>
              </f:facet>
              <af:inputDate value="#{row.bindings.TrfVldFrm.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.displayWidth}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.tooltip}" id="id2">
                <f:validator binding="#{row.bindings.TrfVldFrm.validator}"/>
                <af:convertDateTime pattern="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfVldFrm.format}"/>
              </af:inputDate>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.label}"
                       id="c4">
              <af:inputText value="#{row.bindings.ServiceDesc.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ServiceDesc.tooltip}" id="it3">
                <f:validator binding="#{row.bindings.ServiceDesc.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.label}" id="c5">
              <af:inputText value="#{row.bindings.OtTrfCode.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtTrfCode.tooltip}" id="it4">
                <f:validator binding="#{row.bindings.OtTrfCode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.label}" id="c6">
              <af:inputText value="#{row.bindings.OtUnitRate.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.OtUnitRate.tooltip}" id="it5">
                <f:validator binding="#{row.bindings.OtUnitRate.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.label}" id="c7">
              <af:inputText value="#{row.bindings.NtUnitRate.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.NtUnitRate.tooltip}" id="it6">
                <f:validator binding="#{row.bindings.NtUnitRate.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.label}" id="c8">
              <af:inputText value="#{row.bindings.TrfGrt.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.TrfGrt.tooltip}" id="it7">
                <f:validator binding="#{row.bindings.TrfGrt.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.name}" filterable="true"
                       sortable="true" headerText="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.label}"
                       id="c9">
              <af:inputText value="#{row.bindings.ChargePartyCode.inputValue}"
                            label="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.label}"
                            required="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.mandatory}"
                            columns="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.displayWidth}"
                            maximumLength="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.precision}"
                            shortDesc="#{bindings.ServiceTariffMappingDtlsRVO1.hints.ChargePartyCode.tooltip}" id="it8">
                <f:validator binding="#{row.bindings.ChargePartyCode.validator}"/>
              </af:inputText>
            </af:column>
          </af:table>
        </af:panelCollection>
      </af:panelGroupLayout>
    </jsp:root>

  • How to convert internal table data into excel format?

    Hi all,
    I want to convert internal table data in excel format and then
    send it as email attachment in workflow.
    Please tell me how do i perform this.
    Regards,
    Arpita.

    Hi Arpita,
    Try this sample code::
    Send mail
    maildata-obj_name = 'TEST'.
    maildata-obj_descr = 'Test Subject'.
    loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
    endloop.
    mailrec-receiver = 'your receiver mail id'.
    mailrec-rec_type = 'U'.
    append mailrec.
    call function 'SO_NEW_DOCUMENT_SEND_API1'
    exporting
    document_data = maildata
    document_type = 'EXL'
    put_in_outbox = 'X'
    tables
    object_header = mailtxt
    object_content = mailtxt
    receivers = mailrec
    exceptions
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    others = 8.
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Hope it will help you.
    Regards,
    NIkita

  • Export the Form Data to Excel File using FILE EXPORT

    One problem i am getting...
    I want to export printers page to some excel file using FILE > EXPORT option.
    I login into System Administrator Responsibility > printers > register...
    I want to export this printers data to flat file(EXCEL File) using FILE > EXPORT in the form...
    The movement I click FILE > EXPORT...a flash screen appears and disapperas...nothing will be exported...
    What Might be the problem...
    How can I solve this...
    My FND_LOBS_CTX index is fine..it is valid and

    - Check the security level of the "Trusted sites" zone, make sure it is set to "Low"
    - Make sure you do not have a yellow warning bar
    - Make sure you are not accessing the application through dev60cgi/f60cgi
    - Verify that you have sufficient space in the tablespace (Check init<SID>.ora for any errors)
    - Check the export on some other modules to determine whether the issue is across all Apps or with a specific module only

  • Using OBIEE Scheduler to export and save data in excel/pdf

    Hi
    Is it possible to use obiee scheduler and run particular reports and export the data into excel/pdf and save this file at given location on server.
    env: obiee 11g/linux OS
    Thanks for any ideas.

    Hi,
    Yes it is possible.
    As per my knowledge we don't have such option but we can do one way.
    Using IBOTS you can store specific report and specific time in specific location.
    Note : Using JS script.
    Are you going to implement this way send me your mails id will send you js script for doing this.
    Re: Auto SAVE to excel -- Please refer this thread.
    Create js file using the below script and add this js scrif in your ibot advanced tab.
    var FSO = new ActiveXObject("Scripting.FileSystemObject");
    var foldername = 'D:\IBOT'
    if (FSO.FolderExists(foldername))
    var fileName = foldername + "\\" +Parameter(1);
    var fooFile = FSO.CopyFile(Parameter(0), fileName, true);
    else
    FSO.CreateFolder(foldername);
    var fileName = foldername + "D:\IBOT" + Parameter(1);
    var fooFile = FSO.CopyFile(Parameter(0), fileName, true);
    Thanks,
    Satya

  • Not able to export all table data to excel

    Hi All,
    I am using jdev 11.1.1.4.0
    I want to export all my table data to a excel file.
    I used ADF inbuilt <af:exportCollectionActionListener/> to do the same.
    Also, I have pagination on my JSPX.
    When I click on export button to export the data, it exports current records in the page not all the records.
    For instance, I have 100 records in my table and I am displaying 20 records per page.
    When I click on export to excel image, it exports current 20 records instead of exporting all 100 records.
    Please tell me how to export all the records to the excel.
    Sample code,
    <af:exportCollectionActionListener exportedId="t1" type="excelHTML"/>t1 is id of my table from which I want to export the data.
    also, I have tried exportedRows="all" - but it doesn't work!!!!
    Appreciate your help.
    Thanks and Regards,
    Madhav K.

    Hi Arunkumar,
    thanks for your reply.
    Yes, it works....
    But I don't want to do the same in such way.
    Because almost every page I have export to excel functionality.
    So if follow this way then I have extra table on every page. I don't want this in my application.
    Is there any other way???
    Thanks and Regards,
    Madhav K.

  • How to Export from table view to Excel (not BI query)?

    There is a 'How to' document explaining how to export from an iView using a BI query:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/47fe4fef-0d01-0010-6f87-ed8ecb479123
    However:
    This 'How-To' document is using an example of a BEx query. I am not using a BEx query, therefore I do not have an "Info port". How can I download to Excel from a table view that is not an iView of a BI query? (It is just a internal table coming from a BAPI).

    keenneth,
    i am using the query from SQL server, i am having the same problem of not having info port. so did you find a work around for exporting to excel with filters for non sap queries ?
    any body who had come across this situation , plz guide me.
    thanks in advance
    ravi

  • Exporting fieldsymbol table data to Excel

    hi,
    I'm using dynamic select query and fetching into fieldsymbols table.
    now i want to export above fieldsymbol table data to csv file.
    thanks,
    gupta.

    Hi ,
    You can do the same using GUI_DOWNLOAD. First you need to create one more internal table with one field (length as per ur requirement) and populate this internal table by comma seperator. Then use the FM GUI_DOWNLOAD with file extension CSV.
    Thanks.
    Subhankar

  • How to export the table data to the excel?

    Hi,
    I'm new to WebDynpro. im having a table 5rows and 6 columns, i need the data in the table to be exported to excel sheet by clicking on a button.
    As i went through some of the blogs and tutorials i couldn't understand the procedure, so could any one help out with detailed procedure.
    Thanks & Regards,
      Suresh

    HI! Suresh,
      This is a littile bit complicated process.Here i am trying to expalin the procedure,
    if you are having any problem then let me know.
    Following are the steps:--
    1.create two controls one of type linkToAction and other of type FileDownload and a location on your portal server say it's "/server0/temp/webdynpro/web/local/testexcel.xls"
    2.create a method in your view or controller and call this method as downLoadToXls()
    3.create a Value attribute of type binary in your context,say it's dataContent.
    4.Bind your linkToAction Control to the method downLoadToXls() and control   FileDownLoad data property to dataContent.
    5.In the init() Hook methos write the following code:--
    IWDAttributeInfo attInfo = wdContext.getNodeInfo().getAttribute("dataContent");
    IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)  attInfo.getModifiableSimpleType();
    // In addition the FileDownload UI element needs for defined resource types
    binaryType.setFileName("testexcel.xls");
    binaryType.setMimeType(WDWebResourceType.XLS);
    6.in DownLoadToXls() method add the following code:--
    try {
            out = new FileOutputStream(path);
           workBook = new HSSFWorkbook();
          hsSheet = workBook.createSheet("UserID");
         cs = workBook.createCellStyle();
         cs1 = workBook.createCellStyle();
         cs2 = workBook.createCellStyle();
         dataFormat = workBook.createDataFormat();
         f = workBook.createFont();
         f1 = workBook.createFont();
         f.setFontHeightInPoints((short) 12);
        //make it blue
         f.setColor( (short)HSSFFont.COLOR_NORMAL );
         //make it bold
        //arial is the default font
        f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        //set font 2 to 10 point type
        f1.setFontHeightInPoints((short) 10);
        //make it red
        f1.setColor( (short)HSSFFont.COLOR_RED);
        //make it bold
        f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        f1.setStrikeout(false);
       cs.setFont(f);
       cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
       //set a thick border
       cs2.setBorderBottom(cs2.BORDER_THICK);
       //fill w fg fill color
       cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
       cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
       //set the cell format to text see HSSFDataFormat for a full list
       cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
       cs2.setFont(f1);
       cs2.setLocked(true);
        cs2.setWrapText(true);
        hsSheet.createFreezePane(0,1,1,1);
        row = hsSheet.createRow(0);
         cell = row.createCell((short)0 ,0);
          cell.setCellValue("User ID");
          cell.setCellStyle(cs2);
          cell = row.createCell((short)1 ,1);
          cell.setCellValue("Last Changed Password Date");
          cell.setCellStyle(cs2);
        int nodeSize = wdContext.nodeUserIDAndPass().size();
        for(int jCount=0; jCount < nodeSize; jCount++) {
         row = hsSheet.createRow(jCount+1);
           for(int count = 0; count < 2; count++) {
          if(count == 0) {
         cell = row.createCell((short)0,count);               
    cell.setCellValue(wdContext.nodeUserIDAndPass().getUserIDAndPassElementAt(jCount).getCtx_UserID());
          if(count == 1) {
            cell = row.createCell((short)1,count);
      cell.setCellValue(wdContext.nodeUserIDAndPass().getUserIDAndPassElementAt(jCount).getCtx_ChangedPasswd());
          cell.setCellStyle(cs2);                            
                                                               workBook.write(out);
    out.close();
    //Read the file that was created.
            FileInputStream fin = new FileInputStream(path);
            byte b[] = new byte[fin.available()];
           fin.read(b,0,b.length);
           fin.close();
            wdContext.currentContextElement().setDataContent(b);
      }catch(Exception e)     {
      wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);                   }
    7. Add the follwoing constant at the end:--
    private FileOutputStream out = null;
         private HSSFWorkbook workBook = null;
         private HSSFSheet hsSheet = null;
         private HSSFRow row = null;
         private HSSFCell cell = null;
         private HSSFCellStyle cs = null;
         private HSSFCellStyle cs1 = null;
         private HSSFCellStyle cs2 = null;
         private HSSFDataFormat dataFormat = null;
         private HSSFFont f = null;
         private HSSFFont f1 = null;
         private String path = "/server0/temp/webdynpro/web/local/testexcel.xls";
    8.Add the follwowing jars in your classPath.
    1)poi-3.0.1-FINAL-20070705.jar
    2)jxls.jar
    regards,
    Mithileshwar

  • How to download internal table data to excel in WebUI

    Hi everyone,
    I am trying to download the contents of an internal table to excel in CRM Web UI.
    One way, would be to create a table view and use the export to excel button.
    However, wish to avoid this and directly download using code.
    Also tried converting to xstring and setting data in the response object. However, this works only when I execute the component directly from BSP_WD_CMPWB. In the UI framework however, when I click on custom button(for download), it navigates to a screen where the contents of string are shown directly on browser.
    Is there any other way of doing this?
    Thanks in advance.
    Regards,
    Deepak

    Hi,
    there are two ways to download excel from the webclient using table views. The first is a XML stream that is send to Excel directly. Only works for Excel 2003 and later. The second is the fall back to a .csv.
    I do not know if for the second option a direct connection is established as mentioned in the last post or there is actually a file stream send to the client.
    Anyway the SAP provides the excel download through a seperate webservice. Have a look at CL_CHTMLB_CONFIG_TAB_EXCEL_EXP->IF_HTTP_EXTENSION~HANDLE_REQUEST( ).
    I suppose going the same direction with your excel download will work. This service opens a new download stream with the excel content... Maybe it is even possible to copy it and adjust it to your needs...
    cheers Carsten

  • HOw to convert Oracle Table data to Excel Sheet

    I need to convert Some of fields from my table to Excell sheet. I dont want to use 3rd party tools. Is there any querry to generate Excell sheet????

    There is no direct path to make Excel file from query, instead you may generate a CSV file (comma-separated-values) or TAB separated values file.
    On SQL*Plus
    SQL> set heading off
    SQL> set newpage none
    SQL> set linesize 255 --could be more
    SQL> spool /path/filename.txt
    SQL> select column1||chr(<ascii for Tab>)||column2||...||columnK
    from table
    SQL> spool off
    Hope it helps

  • How to export table data to excel in albpm

    Hi,
    we have an requirement to export table data to excel .
    we have to create an jsp in that jsp we have to have text fileds,we have to enter data to field after that we have to click on save once u click on save that data has to enter in below table and we should provide link to export that table data to excel.
    this is our totatl requirement.can u please suggest me how to do,i dont have any idea..
    Regards,
    Sharmila
    Edited by: user12171025 on Nov 5, 2009 8:44 PM

    Hi Daniel 
    Please have a look at below docs :-
    /people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
    http://wiki.sdn.sap.com/wiki/display/WDJava/ExporttoExcel(WithoutthirdpartyAPIs)
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d01854fd-1579-2c10-63ad-dd62edca2381?quicklink=index&overridelayout=true
    Regards
    Arun Jaiswal

  • How to move large number of internal table data to excel by program

    Hi,
    Iam working on a classical report wherein my requirement is:
    Have around 25 internal tables which I am displaying using a selection screen.I need to transfer this all internal tables data to Excel file by executing.
    Now, let me know how can I transfer all those to excel by execution.
    P.S.: GUI_DOWNLOAD or any other excel download related FMs are used to transfer for single/fewer internal tables.
    But here I need to download 25 internal tables data through program.
    How can I meet the requirement..?
    Kindly advice.
    Thanks,
    Shiv.

    Hi,
    Refer to the following code:
    *& Report  ZDOWNLOAD_PROGRAM
    report  zdownload_program.
    parameter : p_path type rlgrap-filename default 'C:\Pdata.xls'.
    data : gt_output   type standard table of trdirt,
           wa_output   type trdirt,
           p_filen     type string.
    at selection-screen on value-request for p_path.
      clear p_path.
      call function 'F4_FILENAME'
        importing
          file_name = p_path.
    start-of-selection.
      select * from trdirt
               into table gt_output
               where name like 'Z%'
                  or name like 'Y%'.
    end-of-selection.
      move : p_path to p_filen.
      call function 'GUI_DOWNLOAD'
        exporting
      BIN_FILESIZE                    =
          filename                        = p_filen
       filetype                        = 'ASC'
      APPEND                          = ' '
       write_field_separator           =
    cl_abap_char_utilities=>horizontal_tab
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
        tables
          data_tab                        = gt_output
      FIELDNAMES                      =
       exceptions
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         others                          = 22
      if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    Regards
    Rajesh Kumar

  • What is the easiest way to export all tables data from Oracle to MS SQL Server?

    Hello MS,
    I would like to export all tables from Oracle 11.2 to MS SQL Server 2012 R1.
    Using the tool "Microsoft SQL Server Migration Assistant v6.0 for Oracle" did not work for me because there are too many warnings and errors regarding the schema creation (MS cannot know it because they are not the schema designer). My idea is
    to leave/skip the schema creation to the application designer/supplier and instead concentrate on the Oracle data export and MS SQL data import.
    What is the easiest way to export all tables data from Oracle to MS SQL Server quickly?
    Is it:
    - the „MS SQL Import and Export Data“ Tool
    - the “MS SQL Integration Services” Tool
    - not Oracle dump *.dmp format because it is a propritery binary format
    - flat file *.csv (delimited format)
    Thanks!

    Hi lingodingo,
    If you want to directly export all tables from Oracle database to SQL Server, I suggest you use SQL Server Import and Export Wizard. Because you just need to follow the wizard with GUI, this is the easiest way.
    If you want to make some modification for the tables‘ data before loading to SQL Server, I suggest you use SQL Server Integration Services package. For more details, please refer to the following similar thread:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/38b2bed2-9d4e-48d4-a33f-1d9eed1c062d/flat-file-to-sql-server?forum=sqldatamining
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Exporting table data to Excel

    Hello, i use af:exportCollectionActionListener component to export table data to Excel.
    there are 100 000 rows in my table. But only 65 535(may be is consilience that ushort = 0 to 65535) rows was exported.
    what are problems? Anybody know?
    Edited by: Beliansky Alexander on Sep 5, 2012 7:02 AM

    If i am not wrong thats a limit of excel. Not sure but.Google
    taken from "http://msdn.microsoft.com/en-us/library/office/ff700514.aspx"
    "Starting in Excel 2007, the "Big Grid" increases the maximum number of rows per worksheet from 65,536 to over 1 million, and the number of columns from 256 (IV) to 16,384 (XFD). "
    Edited by: in the line of fire on Sep 5, 2012 6:06 PM

Maybe you are looking for

  • Playlist isn't showing up on iTunes?

    I created a playlist on my iPod touch but when I plug it into my computer and open up iTunes, the playlist doesn't show up under the "on my device" panel. I'm not sure if iTunes has always been like this, where it does not recognize the playlist mayb

  • Boot Camp not installing Windows 7 - "No bootable device, insert boot disk and press any key."

    I need some help with something. A while back, I put a brand new hard drive in my MacBook, a 500 GB model to replace the 120 GB one. I cloned everything successfully to the new drive via Carbon Copy Cloner, but now I want to make a Boot Camp partitio

  • Need To Clean Erase My Hard Drive And Re-Install OS and Factory Software

    I have a question. I am needing to erase then reinstall the OS and software that came with this Sep 2008 Macbook Pro. I am selling it and want to wipe out all my personal and work related data files I have created, and do a thorough erase. Then, with

  • Use of Omnipage in combination with Adobe Acrobat

    Hi We were wondering if it is advisable to use Scansoft Omnipage as scanning interface rather than the scanning facility of Adobe Acrobat itself? If Scansoft Omnipage, as a dedicated scanning interface tool, more powerful that Adobe Acrobat's facilit

  • Snapshot too Old Error - Help needed

    One of the batch job is failing due to oracle error "snapshot too old." Please let me know what are the possible reason's this problem occurs and suggest me the possible solutions to rectify this problem. Thanks in advance