Exporting char(string) to excel file using GUI_DOWNLOAD
Dear Team,
When i am trying to export Data of type Char(like 12345678987654321) , after export it convert this data to Floating format(scientific n1E+n2) which is not my desired output .i need to change it using excel cell format control.
suggest me how can i handle this..
Thanks in Advance*.
Hello Santosh,
Play with the below importing parameters in the function module "GUI_DOWNLOAD".
WK1_N_FORMAT - Format for value columns in files of the type WK1
WK1_N_SIZE - Column width for value columns in files of the type WK1
WK1_T_FORMAT - Format for text columns for files of the type WK1
WK1_T_SIZE - Column width for text columns for files of the type WK1.
It might help you I guess. Also read the documentation of those importing parameters by clicking on the long text green icon after the description in the IMPORTING parameters tab of the function module.
Regards,
TP
Similar Messages
-
How to export data to an excel file using VBScript
I'm trying to create a VBScript in DIAdem (V9.1) which automatically saves all the current channels in the data portal to an excel file. I've tried using 'Call ExcelExport' and specify a full file path but the file is never created. What am I doing wrong?
Thanks,
SteveHi Steve,
There are a couple of other things you can try. If you don't like Ingo's suggestion about multiple Excel STP files, your only real option is to create an ASCII file. Note that you can give the ASCII file an extension of *.CSV or even *.XLS, and Excel will read it right in.
So the question boils down to how to format the ASCII export correctly and quickly.
You can use the DAT file approach Ingo mentioned and even re-write the file with VBS to include a few header lines of your own choosing. Note that this approach does NOT support text channels. There is an example of this in the zip file attached below.
You can alternatively use the CSV export function in DIAdem 9.1 to output an ASCII file with the name of each channel as the single header row above all the values. There is an example of this in the zip file attached below.
You can also just read the values from the DIAdem channels and write them out to an ASCII file cell by cell, managing everything with VBScript calls. There is an example of this in the zip file attached below.
I hope that helps,
Brad Turpin
DIAdem Product Support Engineer
National Indstruments
Attachments:
DIAdem ASCII Export.zip 5 KB -
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 -
Generating Excel file using PL/SQL
Hi,
I wanted to generate the excel file using the below pasted PL/SQL which I have downloaded from one of the tech sites. And as I have very limited knowledge about PL/SQL I really dont know how & where I should compile this below mentioned code and get the desired O/P?
Please reply me ASAP if anybody can help me with this?
Please see the below code and please help me to interpret the same.
CREATE OR REPLACE PACKAGE gen_xl_xml IS
-- Version 0.5
-- Objective : The main objective OF this PACKAGE IS TO CREATE excel files from PL/SQL code
-- Requirement : Excel version 2003 onwards support XML format.
-- The procedures does have TO be called IN specific order at this moment.
-- expected SEQUENCE AS OF now IS
-- At first call create_file -> It creates a FILE WITH NAME that you pass AS parameter. This PROCEDURE writes the
-- excel file header AND some basic requirments like default style.
-- procedures 1. create_style , create_worksheet AND write_cell can be used IN ANY SEQUENCE AS many
-- times AS you need.
-- When done WITH writing TO FILE call the PROCEDURE close_file
-- CLOSE FILE --> This will actually flush the data INTO the worksheet(s) one BY one and then close the file.
-- What colors I can use ?
-- red , blue , green, gray , YELLOW, BROWN , PINK . lightgray ,
debug_flag BOOLEAN := TRUE ;
PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL ) ;
PROCEDURE create_excel_apps ;
PROCEDURE create_style( p_style_name IN VARCHAR2
, p_fontname IN VARCHAR2 DEFAULT NULL
, p_fontcolor IN VARCHAR2 DEFAULT 'Black'
, p_fontsize IN NUMBER DEFAULT null
, p_bold IN BOOLEAN DEFAULT FALSE
, p_italic IN BOOLEAN DEFAULT FALSE
, p_underline IN VARCHAR2 DEFAULT NULL
, p_backcolor IN VARCHAR2 DEFAULT NULL );
PROCEDURE close_file ;
PROCEDURE create_worksheet( p_worksheet_name IN VARCHAR2 ) ;
PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL );
PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL );
PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 );
PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) ;
PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER , p_worksheet IN VARCHAR2 ) ;
END ;
-- Package : gen_xl_sml
-- Version : 0.62
CREATE OR REPLACE PACKAGE Body gen_xl_xml IS
-- worksheets must be created before it could be passed AS parameter TO the write cell procedures
l_file utl_FILE.file_type ;
g_apps_env VARCHAR2(1) := 'U' ; -- unset at the start
TYPE tbl_excel_data IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER ;
g_excel_data tbl_excel_data ;
g_null_data tbl_excel_data ;
g_data_count NUMBER ;
TYPE rec_styles IS record ( s VARCHAR2(30) , def VARCHAR2(2000) );
TYPE tbl_style IS TABLE OF rec_styles INDEX BY BINARY_INTEGER ;
g_styles tbl_style ;
g_null_styles tbl_style ;
g_style_count NUMBER := 0;
TYPE rec_worksheets IS record ( w VARCHAR2(30) , whdr VARCHAR2(300), wftr VARCHAR2(2000) );
TYPE tbl_worksheets IS TABLE OF rec_worksheets INDEX BY BINARY_INTEGER ;
g_worksheets tbl_worksheets ;
g_null_worksheets tbl_worksheets ;
g_worksheets_count NUMBER := 0;
TYPE rec_cell_data IS record ( r NUMBER , c NUMBER , v VARCHAR2(2000) ,s VARCHAR2(30) , w VARCHAR2(100), dt VARCHAR2(8) );
TYPE tbl_cell_data IS TABLE OF rec_cell_data INDEX BY binary_INTEGER ;
g_cells tbl_cell_data ;
g_null_cells tbl_cell_data ;
g_cell_count NUMBER := 0 ;
TYPE rec_columns_data IS record( c NUMBER, wd NUMBER, w VARCHAR2(30) ) ;
TYPE tbl_columns_data IS TABLE OF rec_columns_data Index BY BINARY_INTEGER ;
g_columns tbl_columns_data ;
g_null_columns tbl_columns_data ;
g_column_count NUMBER ;
TYPE rec_rows_data IS record( r NUMBER, ht NUMBER , w VARCHAR2(30) ) ;
TYPE tbl_rows_data IS TABLE OF rec_rows_data Index BY BINARY_INTEGER ;
g_rows tbl_ROWS_data ;
g_null_rows tbl_rows_data ;
g_ROW_count NUMBER ;
PROCEDURE p ( p_string IN VARCHAR2) is
begin
IF debug_flag = TRUE THEN
DBMS_OUTPUT.put_line( p_string) ;
END IF;
END ;
FUNCTION style_defined ( p_style IN VARCHAR2 ) RETURN BOOLEAN IS
BEGIN
FOR i IN 1..g_style_count LOOP
IF g_styles(i).s = p_style THEN
RETURN TRUE ;
END IF;
END LOOP ;
RETURN FALSE ;
END ;
-- Function : cell_used returns : BOOLEAN
-- Description : Cell_used FUNCTION returns TRUE IF that cell IS already used
-- Called BY : write_Cell_char, write_cell_num
-- ??? right now it IS NOT called BY write_Cell_null , this needs TO be evaluated
FUNCTION cell_used ( p_r IN NUMBER , p_c IN number , p_w IN VARCHAR2 ) RETURN BOOLEAN IS
BEGIN
FOR i IN 1..g_cell_count LOOP
IF ( g_cells(i).r = p_r AND g_cells(i).c = p_c AND g_cells(i).w = p_w ) THEN
RETURN TRUE ;
END IF;
END LOOP ;
RETURN FALSE ;
END ;
PROCEDURE initialize_collections IS
--- following lines resets the cell data and the cell count as it was
-- observed that the data is retained across the two runs within same seseion.
BEGIN
g_cells := g_null_cells ;
g_Cell_count := 0 ;
g_styles := g_null_styles ;
g_style_count := 0 ;
g_rows := g_null_rows ;
g_ROW_count := 0 ;
g_columns := g_null_columns ;
g_column_count := 0 ;
g_excel_data := g_null_data ;
g_data_count := 0 ;
g_apps_env := 'U';
g_worksheets := g_null_worksheets ;
g_worksheets_count := 0;
END ;
PROCEDURE create_excel_apps is
BEGIN
-- CHECK the env value
IF g_apps_env = 'N' THEN
raise_application_error( -20001 , 'You have already called create_excel ( Non Apps ) procedure, Can not set env to create_excel_apps.');
END IF ;
initialize_collections ;
g_apps_env := 'Y' ;
END ;
PROCEDURE create_excel( p_directory IN VARCHAR2 DEFAULT NULL , p_file_name IN VARCHAR2 DEFAULT NULL )
IS
BEGIN
-- CHECK the env value
IF g_apps_env = 'Y' THEN
raise_application_error( -20001 , 'You have already called procedure create_excel_apps , Can not set env to Non-Apps create_excel.');
END IF ;
initialize_collections ;
g_apps_env := 'N' ;
IF ( p_directory IS NULL OR p_file_name IS NULL ) THEN
raise_application_error( -20001 , 'p_directory and p_file_name must be not null');
END IF ;
BEGIN
-- Open the FILE IN the specified directory
l_file := utl_file.fopen( p_directory, p_file_name , 'w') ;
EXCEPTION
WHEN utl_file.write_error THEN
raise_application_error( -20101 , 'UTL_FILE raised write error, check if file is already open or directory access');
WHEN utl_file.INVALID_OPERATION THEN
raise_application_error( -20101 , 'UTL_FILE could not open file or operate on it, check if file is already open.');
WHEN utl_file.invalid_path THEN
raise_application_error( -20101 , 'UTL_FILE raised invalid path, check the directory passed is correct and you have access to it.');
WHEN others THEN
raise_application_error( -20101 , 'UTL_FILE raised others exception ');
END ;
p( 'File '||p_file_name ||' created successfully');
END ;
PROCEDURE create_style( p_style_name IN VARCHAR2
, p_fontname IN VARCHAR2 DEFAULT NULL
, p_fontcolor IN VARCHAR2 DEFAULT 'Black'
, p_fontsize IN NUMBER DEFAULT null
, p_bold IN BOOLEAN DEFAULT FALSE
, p_italic IN BOOLEAN DEFAULT FALSE
, p_underline IN VARCHAR2 DEFAULT NULL
, p_backcolor IN VARCHAR2 DEFAULT NULL ) is
l_style VARCHAR2(2000) ;
l_font VARCHAR2(1200);
BEGIN
--- CHECK IF this style IS already defined AND RAISE ERROR IF yes
IF style_defined( p_style_name ) THEN
RAISE_application_error( -20001 , 'Style "'||p_style_name ||'" is already defined.');
END IF;
g_style_count := g_style_count + 1;
---- ??? pass ANY value OF underline AND it will only use single underlines
-- ??? pattern IS NOT handleed
IF upper(p_style_name) = 'DEFAULT' THEN
RAISE_application_error( -20001 , 'Style name DEFAULT is not allowed ');
END IF ;
IF upper(p_style_name) IS NULL THEN
RAISE_application_error( -20001 , 'Style name can not be null ');
END IF ;
g_styles(g_style_count).s := p_style_name ;
g_styles(g_style_count).def := ' <Style ss:ID="'|| p_style_name ||'"> ' ;
l_font := ' <Font ' ;
IF p_fontname IS NOT NULL THEN
l_font :=l_font || 'ss:FontName="'|| p_fontname ||'" ';
end if ;
IF p_fontsize is not null then
l_font := l_font ||' ss:Size="'|| p_fontsize ||'" ';
end if ;
IF p_fontcolor is not null then
l_font := l_font ||' ss:Color="'|| p_fontcolor ||'" ';
ELSE
l_font := l_font ||' ss:Color="Black" ';
end if ;
IF p_bold = TRUE THEN
l_font := l_font ||' ss:Bold="1" ' ;
END IF;
IF p_italic = TRUE THEN
l_font := l_font ||' ss:Italic="1" ' ;
END IF;
IF p_underline IS NOT NULL THEN
l_font := l_font ||' ss:Underline="Single" ' ;
END IF ;
-- p( l_font );
g_styles(g_style_count).def := g_styles(g_style_count).def || l_font || '/>' ;
IF p_backcolor IS NOT NULL THEN
g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior ss:Color="'||p_backcolor ||'" ss:Pattern="Solid"/>' ;
ELSE
g_styles(g_style_count).def := g_styles(g_style_count).def || ' <Interior/>';
END IF ;
g_styles(g_style_count).def := g_styles(g_style_count).def || ' </Style>' ;
--- ??? IN font there IS SOME family which IS NOT considered
END ;
PROCEDURE close_file IS
l_last_row NUMBER := 0 ;
l_dt CHAR ; -- ??? Variable TO store the datatype ; this IS NOT used at this time but may be needed IF the memory
-- issue IS there FOR example IF there IS big array
l_style VARCHAR2(140) ;
l_row_change VARCHAR2(100) ;
l_file_header VARCHAR2(2000) := '<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<LastAuthor>a</LastAuthor>
<Created>1996-10-14T23:33:28Z</Created>
<LastSaved>2007-05-10T04:00:57Z</LastSaved>
<Version>11.5606</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9300</WindowHeight>
<WindowWidth>15135</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>120</WindowTopY>
<AcceptLabelsInFormulas/>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>'
BEGIN
IF gen_xl_xml.g_Cell_count = 0 THEN
raise_application_error( -20007 , 'No cells have been written, this version of gen_xl_xml needs at least one cell to be written');
END IF;
IF gen_xl_xml.g_worksheets_count = 0 THEN
raise_application_error( -20008 , 'No worksheets have been created, this version does not support automatic worksheet creation');
END IF;
p( gen_xl_xml.g_Cell_count) ;
-- Write the header xml part IN the FILE.
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := l_file_header ;
p( 'Headers written');
FOR i IN 1..g_style_count LOOP
p( ' writing style number : '||i);
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := g_styles(i).def ;
END LOOP ;
-- CLOSE the styles tag
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Styles>' ;
p( 'worksheet count '|| g_worksheets_count );
FOR j IN 1..g_worksheets_count LOOP
l_last_row := 0 ; --- FOR every worksheet we need TO CREATE START OF the row
p( '()()------------------------------------------------------------ last row '||l_last_row );
--- write the header first
-- write the COLUMN widhts first
-- write the cells
-- write the worksheet footer
l_row_change := NULL ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Worksheet ss:Name="'|| g_worksheets( j).w ||'"> ' ;
p( '-------------------------------------------------------------');
p( '****************.Generated sheet '|| g_worksheets( j).w);
p( '-------------------------------------------------------------');
-- write the TABLE structure ??? change the LINE here TO include tha maxrow AND cell
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Table ss:ExpandedColumnCount="16" ss:ExpandedRowCount="44315" x:FullColumns="1" x:FullRows="1">' ;
FOR i IN 1..g_column_count LOOP
IF g_columns(i).w = g_worksheets( j).w THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Column ss:Index="'||g_columns(i).c||'" ss:AutoFitWidth="0" ss:Width="'||g_columns(i).wd ||'"/> ' ;
END IF;
END LOOP ;
-- write the cells data
FOR i IN 1..g_cell_count LOOP ------ LOOP OF g_cell_count
p( '()()()()()()()()()()()() '|| i);
--- we will write only IF the cells belongs TO the worksheet that we are writing.
IF g_cells(i).w <> g_worksheets(j).w THEN
p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
p( '...Not in this worksheet ');
-- l_last_row := l_last_row -1 ;
ELSE
p( '........................Cell : W :'|| g_worksheets( j).w ||'=> r='|| g_cells(i).r ||',c ='|| g_cells(i).c||',w='|| g_cells(i).w );
IF g_cells(i).s IS NOT NULL AND NOT style_defined( g_cells(i).s ) THEN
-- p(g_cells(i).s) ;
raise_application_error( -20001 , 'Style "'||g_cells(i).s ||'" is not defined, Note : Styles are case sensative and check spaces used while passing style');
END IF;
p( '()()------------------------------------------------------------ last row '||l_last_row );
IF l_last_row = 0 THEN
FOR t IN 1..g_row_count LOOP
p( '...Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
p( '...Changing height') ;
l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
l_last_row := g_cells(i).r ;
EXIT ;
ELSE
p( '...NO change height') ;
l_row_change := NULL ;
END IF ;
END loop ;
IF l_ROW_CHANGE IS NULL THEN
g_data_count := g_data_count + 1 ;
p( '...Creating new row ');
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
l_last_row := g_cells(i).r ;
END IF;
END IF;
IF g_cells(i).s IS NOT NULL THEN
p( '...Adding style ');
l_style := ' ss:StyleID="'||g_cells(i).s||'"' ;
ELSE
p( '...No style for this cell ');
l_style := NULL ;
END IF;
p( '()()------------------------------------------------------------ last row '||l_last_row );
IF g_cells(i).r <> l_last_row THEN
p('...closing the row.'||g_cells(i).r);
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Row>' ;
p( 'ROWCOUNT : '||g_row_count );
FOR t IN 1..g_ROW_count LOOP
p( '.....Height check => Row =' ||g_rows(t).r ||', w='||g_rows(t).w);
IF g_rows(t).r = g_cells(i).r AND g_rows(t).w = g_worksheets(j).w THEN
p( '.....Changing height') ;
l_row_change := ' ss:AutoFitHeight="0" ss:Height="'|| g_rows(t).ht||'" ' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
EXIT ;
ELSE
p( '.....NO change height') ;
l_row_change := NULL ;
END IF ;
END loop ;
-- P( 'Row :'||g_cells(i).r ||'->'|| l_ROW_CHANGE);
IF l_row_change IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' <Row ss:Index="'||g_cells(i).r||'"'|| l_row_change ||'>' ;
END IF;
IF g_cells(i).v IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ></Cell>';
ELSE
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
END IF ;
l_last_row :=g_cells(i).r ;
ELSE
IF g_cells(i).v IS NULL THEN
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' > </Cell>';
ELSE
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '<Cell ss:Index="'||g_cells(i).c||'"' || l_style ||' ><Data ss:Type="'||g_cells(i).dt ||'">'||g_cells(i).v||'</Data></Cell>';
END IF ;
END IF ;
END IF ;
NULL ;
END LOOP ; -- LOOP OF g_cells_count
p('...closing the row.');
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Row>' ;
-- ??? does following COMMENT will have sheet NAME FOR debugging
p( '-------------------------------------------------------------');
p( '....End of writing cell data, closing table tag');
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := ' </Table>' ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := g_worksheets(j).wftr ;
p( '..Closed the worksheet '|| g_worksheets( j).w );
END LOOP ;
g_data_count := g_data_count + 1 ;
g_excel_data( g_data_count ) := '</Workbook>' ;
p( 'Closed the workbook tag');
IF g_apps_env = 'N' THEN
FOR i IN 1..g_data_count LOOP
utl_FILE.put_line( l_file, g_excel_data(i ));
END LOOP ;
utl_file.fclose( l_file );
p( 'File closed ');
ELSIF g_apps_env = 'Y' THEN
FOR i IN 1..g_data_count LOOP
fnd_file.put_line( fnd_file.output , g_excel_data(i));
fnd_file.put_line( fnd_file.log , g_excel_data(i));
END LOOP ;
ELSE
raise_application_error( -20001 , 'Env not set, ( Apps or not Apps ) Contact Support.' );
END IF;
END ;
PROCEDURE create_worksheet ( p_worksheet_name IN VARCHAR2 ) IS
BEGIN
g_worksheets_count := g_worksheets_count + 1 ;
g_worksheets(g_worksheets_count).w := p_worksheet_name ;
g_worksheets(g_worksheets_count).whdr := '<Worksheet ss:Name=" ' || p_worksheet_name ||' ">' ;
g_worksheets(g_worksheets_count).wftr := '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>' ;
END ;
PROCEDURE write_cell_char(p_row NUMBER, p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN VARCHAR2, p_style IN VARCHAR2 DEFAULT NULL ) IS
l_ws_exist BOOLEAN ;
l_worksheet VARCHAR2(2000) ;
BEGIN
-- CHECK IF this cell has been used previously.
IF cell_used( p_row , p_column , p_worksheet_name ) THEN
RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used.Check if you have missed to increment row number in your code. ');
END IF;
-- IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
-- this PROCEDURE just adds the data INTO the g_cells TABLE
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := p_value ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := 'String' ;
END ;
PROCEDURE write_cell_num(p_row NUMBER , p_column NUMBER, p_worksheet_name IN VARCHAR2, p_value IN NUMBER , p_style IN VARCHAR2 DEFAULT NULL ) IS
l_ws_exist BOOLEAN ;
l_worksheet VARCHAR2(2000) ;
BEGIN
-- ??? IF worksheet NAME IS NOT passed THEN use first USER created sheet ELSE use DEFAULT sheet
-- this PROCEDURE just adds the data INTO the g_cells TABLE
-- CHECK IF this cell has been used previously.
IF cell_used( p_row , p_column , p_worksheet_name ) THEN
RAISE_application_error( -20001 , 'The cell ( Row: '||p_row ||' Column:'||p_column ||' Worksheet:'||p_worksheet_name ||') is already used. Check if you have missed to increment row number in your code.');
END IF;
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := p_value ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := 'Number' ;
END ;
PROCEDURE write_cell_null(p_row NUMBER , p_column NUMBER , p_worksheet_name IN VARCHAR2, p_style IN VARCHAR2 ) IS
BEGIN
-- ???? NULL IS allowed here FOR time being. one OPTION IS TO warn USER that NULL IS passed but otherwise
-- the excel generates without error
g_cell_count := g_cell_count + 1 ;
g_cells( g_cell_count ).r := p_row ;
g_cells( g_cell_count ).c := p_column ;
g_cells( g_cell_count ).v := null ;
g_cells( g_cell_count ).w := p_worksheet_name ;
g_cells( g_cell_count ).s := p_style ;
g_cells( g_cell_count ).dt := NULL ;
END ;
PROCEDURE set_row_height( p_row IN NUMBER , p_height IN NUMBER, p_worksheet IN VARCHAR2 ) IS
BEGIN
g_ROW_count := g_ROW_count + 1 ;
g_rows( g_row_count ).r := p_row ;
g_rows( g_row_count ).ht := p_height ;
g_rows( g_row_count ).w := p_worksheet ;
END ;
PROCEDURE set_column_width( p_column IN NUMBER , p_width IN NUMBER, p_worksheet IN VARCHAR2 ) IS
BEGIN
g_column_count := g_column_count + 1 ;
g_columns( g_column_count ).c := p_column ;
g_columns( g_column_count ).wd := p_width ;
g_columns( g_column_count ).w := p_worksheet ;
END ;
END ;
SHOW errors ;
Thanks,
Maddy BHi,
Peter Gjelstrup wrote:
Next thing is how to use it:
declare
k_file constant varchar2(30) := 'YourFile.xls'
begin
create_file(k_file);
-- Call other procedures
close_file;
end;
Don't forget: these procedures are all part of the gen_xl_xml package.
To call them from outside the package, you have to prefix each procedure name with the package name, like this:
declare
k_file constant varchar2(30) := 'YourFile.xls'
begin
gen_xl_xml.create_file(k_file);
-- Call other procedures
gen_xl_xml.close_file;
end; -
How to get Header in Downloaded .xls file using GUI_Download function
How to get Header in Downloaded .xls file using GUI_Download function ???
How to use the the Header parameter available in GUI_Download function .HI,
see this sample code..
data : Begin of t_header occurs 0,
name(30) type c,
end of t_header.
data : Begin of itab occurs 0,
fld1 type char10,
fld2 type char10,
fld3 type char10,
end of itab.
DATA: v_pass_path TYPE string.
append itab.
itab-fld1 = 'Hi'.
itab-fld2 = 'hello'.
itab-fld3 = 'welcome'.
append itab.
append itab.
append itab.
append itab.
append itab.
t_header-name = 'Field1'.
append t_header.
t_header-name = 'Field2'.
append t_header.
t_header-name = 'Field3'.
append t_header.
CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
default_extension = 'XLS'
IMPORTING
fullpath = v_pass_path.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_pass_path
filetype = 'DBF'
TABLES
data_tab = itab
FIELDNAMES = t_header
Cheers,
jose. -
I would like to upload a excel file using jsp
Hi,
I would like to upload the excel file using jsp in my netbeans ide. Please help.
I don Know what is the error in this jsp file. It is not showing any thing and the file is also not getting uploaded.
Please gothru the code below.
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.io.*" errorPage="err.jsp"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<html:rewrite page="/design.css" />" rel="stylesheet" type="text/css">
<title>Upload Page</title>
</head>
<body onKeyDown="DisablingBackFunctionality()" onLoad="DisablingBackFunctionality()">
<html:form action="download" >
<div style="position:absolute; left:100;top:200;">Select an excel File :<input type="file" name="uploadfile"></div>
<div style="position:absolute; left:190;top:250;"><input type="submit" name="Submit" value="Read"></div>
<div style="position:absolute; left:336;top:250;"><input type="reset" name="Reset" value="Clear"></div>
mainmenu
</html:form>
</body>
</html>
<%
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
String file = new String(dataBytes);
//out.println("<br> file :"+file);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
//out.println("<br> savefile :"+saveFile);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//out.println("<br> now file1 :"+saveFile);
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
//out.println("<br> now file2 :"+saveFile);
//out.print(dataBytes);
String ext = "";
if (saveFile.indexOf(".") != -1) {
ext = saveFile.substring(saveFile.lastIndexOf("."));
int lastIndex = contentType.lastIndexOf("=");
//out.println("<br>lst index of"+lastIndex);
String boundary = contentType.substring(lastIndex + 1, contentType.length());
//out.println("<br> boundary"+boundary);
//out.println("<br> file :"+file);
int pos;
pos = file.indexOf("filename=\"");
//out.println("<br> now 0 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 1 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 2 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 3"+pos);
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
FileOutputStream fileOut = new FileOutputStream("D:\\" + saveFile);
//FileOutputStream fileOut = new FileOutputStream(saveFile);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
session.setAttribute("fil", saveFile);
//out.println("File saved as " +saveFile);
%>
<script type="text/javascript" >
function DisablingBackFunctionality()
var URL;
var i ;
var QryStrValue;
URL=window.location.href ;
i=URL.indexOf("?");
QryStrValue=URL.substring(i+1);
if (QryStrValue!='X')
window.location=URL + "?X";
</script>
Please let me know the result as soon as possible. Its my very urgent.
Thanking Yu,
Muthu Kumar.RNo.
Mylenium -
How to upload an excel file using ABAP.
Hi,
Can anyone please help me in understanding how to upload an excel file using ABAP.
Thanks!!http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
check the link
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function ALSM_EXCEL_TO_INTERNAL_TABLE
exporting
filename = p_infile
i_begin_col = 1′
i_begin_row = 2′ Do not require headings
i_end_col = 14′
i_end_row = 31′
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when 0001′. First name
wa_record-name1 = itab-value.
when 0002′. Surname
wa_record-name2 = itab-value.
when 0003′. Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop. -
Can't read special characters in an excel file using JDBC
Hi! I 've a code to read an excel file using JDBC-ODBC bridge. I can read the values, but any special characters is readed wrong, just symbols. The special characters are of spanish language. This is my code:
Locale currentLocale;
currentLocale = new Locale("es", "MX");
Locale.setDefault(currentLocale);
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=comisionesperfiles.xls");
stmnt = c.createStatement();
String query = "Select * from [Hoja1$]" ;
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() ){
String valor = rs.getString(2) ;
if(valor != null && !"null".equalsIgnoreCase(valor)){
if(!comisiones.contains(valor)){
System.out.println(valor);
comisiones.add( valor );
rs.close();
stmnt.close();As you can see, I've tried to set the locale, but it didn't work.
I'm using Excel 2003, Java Version 1.4.2_07 and Windows XP Professional (in latin american spanish).
Hope someone can help me!FYI: Apache's POI can read/write Excel files in Java:
http://jakarta.apache.org/poi/index.html -
How to get field separator in flat file using GUI_DOWNLOAD function
hi,
how to get field separator in flat file using GUI_DOWNLOAD function.
thanking you.Hi,
Use WRITE_FIELD_SEPARATOR = 'X'.
Check this sample code
REPORT z_file_download.
DATA: w_name(90) TYPE c.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
price LIKE sflight-price,
currency LIKE sflight-currency,
END OF fs_flight.
DATA:
BEGIN OF fs_head,
carrid(10) TYPE c,
connid(10) TYPE c,
fldate(10) TYPE c,
price(10) TYPE c,
curr(10) TYPE c,
END OF fs_head.
DATA:
t_head LIKE
TABLE OF
fs_head.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
fs_head-carrid = 'CARRID'.
fs_head-connid = 'CONNID'.
fs_head-fldate = 'FLDATE'.
fs_head-price = 'PRICE'.
fs_head-curr = 'CURRENCY'.
APPEND fs_head TO t_head.
SELECT-OPTIONS:
s_carrid FOR fs_flight-carrid.
START-OF-SELECTION.
SELECT carrid
connid
fldate
price
currency
FROM sflight
INTO TABLE t_flight
WHERE carrid IN s_carrid.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'D:\flight.xls'
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
* 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 = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = t_head
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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:\flight.xls'
filetype = 'ASC'
append = 'X'
write_field_separator = 'X'
TABLES
data_tab = t_flight
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 EQ 0.
MESSAGE 'Download successful' TYPE 'I'.
ENDIF.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Creation of Excel files using XSLT
Hi frnds,
From the blog provided by the Michal
/people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
I came to know that we can create excel files using XSLT mapping but here inthis blog the example provides creation of only one column but I have a scenario where in I want 3 columns ex:Name,Age,***
Shiva 26 Male
Ravi 25 Male
Rani 24 Female
but using the code provided in Michal blog Im getting the output as
Shiva
26
Male
Ravi
25
Male
Rani
24
Female
Can anyone help me in modifying the code given in Michal blog to get the output as required.
Please share your ideas or suggestion onthis...
Thanks in advance,
Shiva.Please change the code as
<xsl:template match="file_SDN/recordset/data/*">
<Row>
<Cell>
<Name ss:Type="String">
<xsl:apply-templates/>
</Name>
<Age ss:Type="Integer">
<xsl:apply-templates/>
</Age>
<*** ss:Type="String">
<xsl:apply-templates/>
</***>
</Cell>
</Row>
</xsl:template> -
How to read the excel file using webdynpro abap?
Hi,
how to read and modify excel file using webdynpro abap?
Regards,
PavaniFor reading excel file follow the steps :
1. Use a File upload UI element and bind it with xstring.
2. Now your excel will be uploaded and stored in Xstring.
3. Convert Xstring to String data using FM 'HR_KR_XSTRING_TO_STRING'.
4. Now split the string at new line so as to make an internal table .
Ex . SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE it_table.
here it_table is type table of string.
5.now loop at the internal table and separate the content of this table separated by tab.
Ex. SPLIT wa_table AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_new.
it_new type string_table.
6. For more info , refer this thread :
Re: How to upload excel file in Webdynpro application using ABAP -
How can I create an csv/excel file using pl/sql and then sending that file
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.968776 wrote:
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
Whay do you want database (pl/sql) code to do these things?
Anyhow, you may be interested in :
{message:id=9360007}
{message:id=9984244} -
Read an excel file using JSP in MII 12.1
Hi,
I want to read an excel file using jsp page. I dont want to use the UDS or ODBC for connecting to excel.
I am trying to use org.apache.poi to read the excel file in jsp page.
While running, its showing a compilation error "package org.apache.poi.hssf.usermodel does not exist"
I have the jar files for it, where do we need to upload it so that jsp page works.
Thanks a lot
Regards,
Neha MaheshwariThe user doesn't want to save the excel file in server.
I want to upload file and save its contents in database.
I have the code to read and save excel data in database but not able to get the location to deploy the jar file.
In general, if we are creating a jsp page in MII workbench which is using some jar file.
Whats the location to upload this jar file so that the jsp page works correctly? -
Writing into Excel file using PL/SQL and formatting the excel file
Hi,
I am writing into a excel file using PL/SQL and I want to make the first line bold on the excel. Also let me know if there are any other formatting options when writing into excel.
Regards,
-AnandI am writing into a excel file using PL/SQL
Re: CSV into Oracle and Oracle into CSV
check that thread or search in this forum... -
Append in same file using GUI_DOWNLOAD file type is pdf
Hi All
I have three internal tables and want to append in same pdf file using GUI_DOWNLOAD . My problem is this when i m using the same file it overwrites it i also mark APPEND = 'X' . Can anybody help me how can i append.
Thanks
VikiHi
Try
http://help.sap.com/saphelp_nw04/helpdata/en/60/f8123e9c6c498084f9f2bafab32671/content.htm
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
https://www.sdn.sap.com/irj/sdn?rid=/webcontent/uuid/24b9e126-0b01-0010-e098-f46384fad9f3 [original link is broken]
Regards
Raj
Maybe you are looking for
-
Why is the Samsung module a quarter the price compared with the one from the Apple Store? http://store.apple.com/jp_edu_1460/memorymodel/ME_2_66_MACMINI compared with http://www.dospara.co.jp/5shopping/detail_parts.php?bg=1&br=30&sbr=471&ic=154499 &f
-
ATI HD 6000 / 7000 series support in CS6?
Hey all, I've been planning on snagging a GTX 570 for a while, for my upcoming use w/ Adobe Premiere. Are ATI cards being supported more w/ CS6? I may have to rethink my purchase if they are, since it appears that some of the ATI cards offer better b
-
Need help with new email problem
Hi friends . . . I'm not sure if this is a forum that could help me figure out my new problem . . . but I'll give it a try. . .I need some help . . . My email is sometimes being sent to the wrong address. Instead of my Yahoo address, they're sent to
-
Database Upgrade in Data Gaurd
Hi all, i have an active data guard running i wont to upgrade my database what should i do?? should i stop my dataguard shutdown both primary database and secondary database upgrade primary first then secondary database, then i'll make again dataguar
-
May i create an apple ID without paying info.?
i try many times to creat an apple id without filling in payment info. itunes just tell me to contact itunes support for finishing the creating.