Export the sql output to an excel file
Hi,
I would llke to know how can we export an sql query out put from oracle 9i to an excel file using a java code...
Thanks in advance..
Naveen
Naveen,
You can access Microsoft Excel files via JDBC using the "JdbcOdbc" driver that comes with the JDK.
Hence a simple matter of using JDBC to both extract from Oracle and insert into Excel.
You will find many resources on the Internet explaining how to do this.
Please note that I am certain that this is not the only way to achieve this.
Good Luck,
Avi.
Similar Messages
-
How to export the text edit data to excel file without splitting the data in excel file?
how to export the text edit data to excel file without splitting the data in excel file?
I have a requirement in SAP HR where in the appraiser can add comments in the area given and can export that to excel file. Currently the file is getting exported but the comments getting split into deifferent rows.
I want the entire comment to be fit in one row.
Please help.
Thank youHi,
if your text edit value is stored in 'lv_string' variable.
then before exporting the value to excel you have to remove CL_ABAP_CHAR_UTILITIES=>NEWLINE
that is '#' from the variable lv_string.
for that use code some thing like this.
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE in lv_string WITH space.
I think this will do the trick. -
How to export the sql output to Excel?
I installed Raptor on my system. I ran few reports and trying to figure out how to save the reprots to excel srpeasheet format. I just see 'save' but not sure where the output is saved and with what filename. Saveas is grayed out all the time.
Unfortunately, there are some things that Excel gets confused going through CSV files (or copy and pate). For example, our task number structure within Oracle Projects is to name each task with the super-task number "-" sub task number (10, 10-1, 10-2, 10-3, etc). As soon as you are not directly creating the Excel file, Excel will interpret the "10-1", "10-2", etc as dates - 10-Jan, 10-Feb for our date format and presumably 1-Oct, 2-Oct for US date format.
I have just tested exporting the data to CSV and then opening in Excel and also selecting all data, copying and pasting into Excel and both convert "10-1" to 10-Jan (assumes current year).
You get similar issues with text columns that contain only numeric values (for example our employee numbers are stored in a text field, but are numeric and left passed with zeros to ensure consistent length), or a mixture of numeric values and alpha-numeric values. -
How to send the report output to the application server in a excel file
Hello,
how to send the report output to the application server in a excel file.
and the report runs in background.
Thanks in advance.
SundeepDear Sundeep.
I'm providing you with the following piece of code ... Its working fine for me ... hopefully it suits your requirement ...
D A T A D E C L A R A T I O N *
TYPES: BEGIN OF TY_EXCEL,
CELL_01(80) TYPE C,
CELL_02(80) TYPE C,
CELL_03(80) TYPE C,
CELL_04(80) TYPE C,
CELL_05(80) TYPE C,
CELL_06(80) TYPE C,
CELL_07(80) TYPE C,
CELL_08(80) TYPE C,
CELL_09(80) TYPE C,
CELL_10(80) TYPE C,
END OF TY_EXCEL.
DATA: IT_EXCEL TYPE STANDARD TABLE OF TY_EXCEL,
WA_EXCEL TYPE TY_EXCEL..
E V E N T : S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Here you populate the Internal Table.
Display - Top of the Page.
PERFORM DISPLAY_TOP_OF_PAGE.
E V E N T : E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
SET PF-STATUS 'GUI_STATUS'.
E V E N T : A T U S E R - C O M M AN D *
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'EXPORT'.
Exporting the report data to Excel.
PERFORM EXPORT_TO_EXCEL.
ENDCASE.
*& Form DISPLAY_TOP_OF_PAGE
text
--> p1 text
<-- p2 text
FORM DISPLAY_TOP_OF_PAGE .
SKIP.
WRITE: /05(128) SY-ULINE,
/05 SY-VLINE,
06(127) 'O R I C A'
CENTERED COLOR 1,
132 SY-VLINE.
WRITE: /05(128) SY-ULINE,
/05 SY-VLINE,
06(127) 'Shift Asset Depreciation - Period/Year-wise Report.'
CENTERED COLOR 4 INTENSIFIED OFF,
132 SY-VLINE.
WRITE: /05(128) SY-ULINE.
E X C E L O P E R A T I O N
CLEAR: IT_EXCEL[],
WA_EXCEL.
PERFORM APPEND_BLANK_LINE USING 1.
WA_EXCEL-cell_02 = ' XYZ Ltd. '.
APPEND WA_EXCEL TO IT_EXCEL.
CLEAR: WA_EXCEL.
WA_EXCEL-cell_02 = 'Shift Asset Depreciation - Period/Year-wise Report.'.
APPEND WA_EXCEL TO IT_EXCEL.
PERFORM APPEND_BLANK_LINE USING 1.
ENDFORM. " DISPLAY_TOP_OF_PAGE
*& Form APPEND_BLANK_LINE
text
-->P_1 text
FORM APPEND_BLANK_LINE USING P_LINE TYPE I.
DO P_LINE TIMES.
CLEAR: WA_EXCEL.
APPEND WA_EXCEL TO IT_EXCEL.
enddo.
ENDFORM.
*& Form EXPORT_TO_EXCEL
text
--> p1 text
<-- p2 text
FORM EXPORT_TO_EXCEL .
DATA: L_FILE_NAME(60) TYPE C.
Create a file name
CONCATENATE 'C:\' 'Shift_Depn_' SY-DATUM6(2) '.' SY-DATUM4(2)
'.' SY-DATUM+0(4) INTO L_FILE_NAME.
Pass the internal table (it_excel which is already populated )
to the function module for excel download.
CALL FUNCTION 'WS_EXCEL'
exporting
filename = L_FILE_NAME
tables
data = IT_EXCEL
exceptions
unknown_error = 1
others = 2.
if sy-subrc <> 0.
message e001(ymm) with 'Error in exporting to Excel.'.
endif.
ENDFORM. " EXPORT_TO_EXCEL
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When you click the button - Export to Excel ( GUI-Status) you'll be able to export the content of the Internal Table to an Excel file .......
Regards,
Abir
Don't forget to award Points * -
Saving sql query result as excel file in different spreadsheets
Hi,
I have exported the output of sql into excel sheet as follow:
SET LINESIZE 80
SET PAGESIZE 0
SET FEEDBACK OFF
SET SPOOL ON
SET TERMOUT OFF
SPOOL current_employees.csv
SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
set colsep ,
SELECT * FROM sales;
SPOOL OFF
But my question is how can I export SQL output in multiple excel spredsheets?
Is there anything by which I can switch my spreadsheets through the above SQL script?
Regards,
AshishHi,
I have exported the output of sql into excel sheet as follow:
SET LINESIZE 80
SET PAGESIZE 0
SET FEEDBACK OFF
SET SPOOL ON
SET TERMOUT OFF
SPOOL current_employees.csv
SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
set colsep ,
SELECT * FROM sales;
SPOOL OFF
But my question is how can I export SQL output in multiple excel spredsheets?
Is there anything by which I can switch my spreadsheets through the above SQL script?
Regards,
Ashish -
Introduction
There is a scenario that a report grouped by one field for some reasons, then the users want to export each group data to separated Excel files. By default, we can directly export only one file at a time on report server. Is there a way that we can split
the report based on the group, then export each report to Excel file?
Solution
To achieve this requirement, we can add a parameter with the group values to filter the report based on the group, then create a data-driven subscription for the report which get File name and parameter from the group values.
In the report, create a parameter named Name which use the Name field as Available Values (supposing the group grouped on Name field).
Add a filter as below in the corresponding tablix:
Expression: [Name]
Operator: =
Value: [@Name]
Deploy the report. Then create a data-driven subscription with Windows File Share delivery extension for the report in Report Manager.
During the data-driven subscription, in the step 3, specify a query that returns the Name field with the values as the group in the report.
In the step 4 (Specify delivery extension settings for Report Server FileShare), below “File name”option, select “Get the value from the database”, then select Name field.
Below ‘Render Format’ option, select Excel as the static value.
In the step 5, we can configure parameter Name “Get the value from the database”, then select Name field.
Then specify the subscription execute only one time.
References:
Create a Data-Driven Subscription
Windows File Share Delivery in Reporting Services
Applies to
Reporting Services 2005
Reporting Services 2008
Reporting Services 2008 R2
Reporting Services 2012
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Thanks,
Is this a supported scenario, or does it use unsupported features?
For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
in a supported way?
Thanks! Josh -
How to export the entire databse in a text file !!!
I have oracle 11g Database and want to export the SH Database as a text file
What will be the process to export it ?
links or steps
ThanksI have oracle 11g Database and want to export the SH Database as a text file
What will be the process to export it ?
links or steps I think there is no such operation, But you have some alternate.
1) take export of database
2) import into SQL file.
one of example
http://www.dba-oracle.com/t_data_pump_sqlfile_parameter.htm -
Hi everyone,
Can you export the date and user to Excel that appears into a Comments field in a tracking list?
When i export a tracking list with a Comment field in the Content type, the screen where you enter the data for an item, the Comments field just export the text of the comment into the Excel file.
In the Comments field appears also, besides the comment text, the user and date from who and when the comment is added.
Is there a way to export also the user and the date?
Thanks
Wimcreate another comment field that doesn't use 'appending', and through SP Designer change workflow keep
updating that field with the new comments (prepend the field with date/username/new comment). Hide the field on all forms, but put it in the view you need to export to Excel.
Please refer few more links: Hope they will help
http://www.nothingbutsharepoint.com/2009/04/16/versioning-append-changes-to-existing-text-view-entries-aspx/
http://sympmarc.com/2011/02/07/showing-all-versions-of-append-changes-to-existing-text-in-a-data-view-web-part-dvwp/comment-page-3/
https://mossipqueen.wordpress.com/2013/03/06/display-all-appending-field-entries-in-a-single-list-view/
http://community.office365.com/en-us/f/154/t/278560.aspx
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply. -
Issue with Saving the Query output data in Excel format
Hi,
Recnetly we had upgraded from 4.6c to ECC 6.0.
In ECc 6.0 environment, when user try to export the query output , we are getting only XML option to save the data.
But user want to save the data in EXcel format, he was able to do that in 4.6C.
pleas eprovide some inputs, on this issue.
Thanks,
Sanketh.I cannot for the life of me imagine, why a link to a post in the 'Business One Forum' where one uses ODBC to transfer query-data to MicroSoft Excel is of relevance to the OPs question, even if the same is not a security issue.
Never mind. [note 40155|https://service.sap.com/sap/support/notes/402155] deals with various symptoms in the ALV-Excel combination as as of release 4.6C. There are various others, mostly in components BC-SRV-ALV and BC-ABA-LI - also: I remember that when we upgraded from 4.5B to 4.7C there was an issue with Excel-templates -> the solution was in the release notes somewhere. So, in addition to SMP you might want to check the release notes and/or upgrade guide for solutions.
And yes, moderators ... this is not a security issue, this should go to ECC-Applications/Upgrade. -
Hello All,
I have a requirement to send/export the background job spool in Excel (in MHTML format) in ECC 6.0. Please help.
Thank you.
NaliniHi Jigar,
Thanks for your response.
Anything is like download to desktop or email is fine. But in MHTML format.
We can download the ALV report in MHTML spreadsheet format when we run the program online. But the program is running for long time and going to dump.
So i scheduled it as background job and downloading the output in .HTML format. But user wants the spool/report output in .MHTML spreadsheet format.
I can write the code. Instead of changing the existing program I would like to know is there any way (from standard SAP) that I can get the background spool in MHTML spreadsheet format.
Thanks,
Nalini -
Trying to send the alv's information to excel file
Hello iam trying to send the alv's information, when i execute my program sent an alv with that information that i have selected and then i would like to sent that information that the alv containe to an excel file, that why i press the button located top of alv, this sent an excel screen but this screen appears plain,without information but doesn't send an error.
thanks a lot for you helpMr Heilman:
I am really sorry for to many question and this troubles
this is the segment fo code that i am using:
*& Report ZREPORTE_PA9011
REPORT zreporte_pa9011 NO STANDARD PAGE HEADING MESSAGE-ID 02.
*Tables declaration
TABLES pa9011.
TYPES BEGIN OF prueba.
INCLUDE STRUCTURE pa9011.
TYPES END OF prueba.
DATA prueba TYPE STANDARD TABLE OF prueba WITH HEADER LINE.
*declaracion de las variables para el alv
TYPE-POOLS: slis.
DATA: repname LIKE sy-repid, "variables alv
heading TYPE slis_t_listheader,
layout TYPE slis_layout_alv,
fieldtab TYPE slis_t_fieldcat_alv.
*Sections parameters
SELECTION-SCREEN: BEGIN OF BLOCK bi WITH FRAME TITLE text-001.
SELECT-OPTIONS subtipo FOR pa9011-subty.
PARAMETER: pbegda LIKE pa9011-begda.
SELECTION-SCREEN: END OF BLOCK bi.
START-OF-SELECTION.
repname = sy-repid.
PERFORM selecciona_datos.
PERFORM transfer_to_alv.
*& Form selecciona_datos
text
FORM selecciona_datos.
REFRESH prueba.
SELECT * INTO CORRESPONDING FIELDS OF TABLE prueba FROM pa9011
WHERE subty IN subtipo
AND begda GT pbegda.
IF sy-subrc NE 0.
MESSAGE e000 WITH 'Aun no existen datos cargados'.
ENDIF.
ENDFORM. "selecciona_datos
*& Form transfer_to_alv
send the information from prueba into alv
FORM transfer_to_alv.
PERFORM initialize_fieldcat USING fieldtab[].
PERFORM build_layouts USING layout.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repname
i_callback_user_command = 'AT_USER_COMMAND'
i_callback_top_of_page = 'BUILD_COMMENT'
i_structure_name =
is_layout = layout
it_fieldcat = fieldtab[]
i_default = 'X'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = PRUEBA
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "transfer_to_alv
*& Form initialize_fieldcat
text
-->P_FIELDTAB text
FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
REFRESH p_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'PRUEBA'.
l_fieldcat-ref_tabname = 'PA9011'.
l_fieldcat-sp_group = 'A'.
l_fieldcat-fieldname = 'SUBTY'.
l_fieldcat-seltext_m = text-t01.
l_fieldcat-col_pos = 1.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'BEGDA'.
l_fieldcat-seltext_m = text-t02.
l_fieldcat-col_pos = 2.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ENDDA'.
l_fieldcat-seltext_m = text-t03.
l_fieldcat-col_pos = 3.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'AEDTM'.
l_fieldcat-seltext_m = text-t04.
l_fieldcat-col_pos = 4.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'UNAME'.
l_fieldcat-seltext_m = text-t05.
l_fieldcat-col_pos = 5.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'PREAS'.
l_fieldcat-seltext_m = text-t06.
l_fieldcat-col_pos = 6.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZDESCRSEGURO'.
l_fieldcat-seltext_m = text-t07.
l_fieldcat-col_pos = 7.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZASEGURADORA'.
l_fieldcat-seltext_m = text-t08.
l_fieldcat-col_pos = 8.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-fieldname = 'ZCOBERTURA'.
l_fieldcat-seltext_m = text-t09.
l_fieldcat-col_pos = 9.
APPEND l_fieldcat TO p_fieldtab.
ENDFORM. "initialize_fieldcat
*& Form build_layouts
text
FORM build_layouts USING p_layout TYPE slis_layout_alv.
p_layout-colwidth_optimize = 'X'.
p_layout-zebra = 'X'.
p_layout-f2code = '&ETA'.
p_layout-detail_popup = 'X'.
ENDFORM. "build_layouts
*& Form build_comment
text
FORM build_comment.
DATA: hline TYPE slis_listheader,
text(60) TYPE c.
REFRESH heading.
CLEAR: hline, text.
hline-typ = 'H'.
text = text-h01.
hline-info = text.
APPEND hline TO heading.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = heading.
ENDFORM. "build_comment -
main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)
The path(Grundpfad)for the excel file should be inserted in the main.vi.1. There's a shipping example called Write Table To XL.vi (Help>Find Examples>Communicating with External Applications>ActiveX>Excel) that you can use as a starting point.
2. Buy the LabVIEW Report Generation Toolkit. Info can be found here.
3. Search this forum for other examples of writing to Excel. -
How to export the data from table to excel sheet
hi experts i have some problem am trying to export the data fro table to Excel sheet in the view controller i have created one button wit public void onActionCLEAR(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionCLEAR(ServerEvent)
//wdContext.nodeBapi_Salesorder_Getlist_Input().
//wdContext.nodeBapi_Salesorder_Getlist_Input().invalidate();
//@@end
//@@begin javadoc:onActionExporToExcel(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onActionExporToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionExporToExcel(ServerEvent)
try{
FileOutputStream fos=new FileOutputStream("Test.xls");
PrintStream ps=new PrintStream(fos);
ps.println("<html><body><table border=1>");
int size=wdContext.nodeBapi_Salesorder_Getlist_Input().size();
Iterator attributes=wdContext.getNodeInfo().iterateAttributes();
ps.println("<tr>");
while(attributes.hasNext()){
ps.println("<th>");
DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
ps.println(attrName.getName());
ps.println("</th>");
ps.println("</tr>");
for(int i=0; i<wdContext.nodeBapi_Salesorder_Getlist_Input().size();i++)
attributes=wdContext.getNodeInfo().iterateAttributes();
ps.println("<tr>");
IWDNodeElement ele=wdContext.getElementAt(i);
while(attributes.hasNext()){
ps.println("<td>");
DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
ps.println(""+ele.getAttributeAsText(attrName.getName()));
ps.println("</td>");
ps.println("</tr>");
ps.println("</table></body></html>");
ps.flush();
ps.close();
fos.close();
catch(Exception e){
wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
finally{
//return("Test.xls") ;
//@@end
}h action and i have return the code
its running sucessfully but am not able to perform the action plz help meHi,
You shouldn't use DataAttributeInfo as it is an internal object, if I'm correct.
Use IWDAttributeInfo instead of DataAttributeInfo and it should work
(See also API doc of IWDNodeInfo.iterateAttributes() at http://help.sap.com/javadocs/nwce/ce711sp02/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDNodeInfo.html#iterateAttributes())
Cheers,
Robin -
How to display the out put of the sql query in a text file using forms
I want to display the out put of the sql query in a text file using forms 6.0.Same could be done using spool command in sqlplus but i want it using forms....Fiaz
Have a look at the text_io package:
http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=f1_help/oraini/c_text_io.html&vtTopicId=
cheers -
Display the query result in an Excel file??
hi there..
am writing one script file that queries my DB and display the query result in an Excel file??
i.e: if my query is :
select col1, col2
from table;
and i want the results to dispalys in 2 col. in an Excel spreadsheet..
Appreaciating ur cooperation..
Mouradset colsep to a delimiter that is not normally part of your data like |
also setup the environment with these other setup commands
Set Echo Off;
Set Concat Off;
Set Pagesize 9999;
Set Feedback Off;
Set Verify Off;
Set Term Off;
Set Space 0;
Set Colsep '|'
Set Underline Off;
If you wanted to use a comma delimiter the setup would be same but the set colsep='","'
with the addition of concatenating a " on the first col and last col of the query
eg.
-- if first col and last_col are character types then
SELECT '"'||col1,....,last_col||'"'
FROM table;
Otherwise if either is a number they would have to be converted with a TO_CHAR
Maybe you are looking for
-
Create inbound delivery for same material with multiple batches
Hi Experts, An ASN( advanced shipping notification) contains multiple batch numbers for same material or line item.An IDOC has different segments with batch numbers but in SAP while creating Inbound delivery(VL31N) only batch number ( segment) get po
-
CVS get module list doesn't function in JDev 10.1.2
Hi I created a sspi CVS connection in JDev 10.1.2 and everthing is OK but I can't get list of modules in CVS repository. Also I tried the same thing in JDev 10.1.3 Preview and it's OK. Thanks.
-
Finder Keeps Having To Re-generate Icon Previews
Hi, I love the new Icon Previews in Leopard, when showing files in Icon view. However, every time you log into Leopard Finder has to regenerate those previews from scratch, which, if you've got a folder full of 100 PDFs, can take a long time. It woul
-
Configuration Changes logging issue, ASDM related?
I've run into an interesting problem. ASA: 8.4(2) ASDM: 6.4(5) When I make a change at the CLI, syslog message ASA-5-111008 is generated and sent to the syslog servers, local buffer, and ASDM. When I make a change in ASDM, syslog message ASA-5-111008
-
Can DW edit sites built with Frontpage extensions
I have to work on a site that was originally created by someone who used frontpage and frontpage extensions. Im basically just redesigning the layout our outer shell, and adding all the old data inside the design. There are about 20-30 forms in this