How to set default cell format 'text' instead of 'general' sheet in excel using pl/sql code?

Can someone please help me on how to generate excel file using pl/sql? I have generated csv files successfully, but now I need to generate a excel. I changed the code generation of the csv file, but the file gives me error when opening:

"The file you are trying to open,"XXXX.xls", is in a different format than specified by the file extension. Do you want to open it now? »

If I choose Yes then open the excel file, but it excludes the leading 0 in the front for one my column. How do I configure excel type default column as text rather than General, when you create the files? I also tried to generate excel file using xml. But I do not know how to set the type of column there, too. I'm using Oracle 11.2.0.3.0 and APEX 4.2.6.00.03. I'll call all these codes apex.

Code1 is used:

Declare

output_header varchar2 (4000);

fichier_en_sortie VARCHAR2 (255);

Varchar2 (2) EOL: = Chr (13) | Chr (10);

BEGIN

output_header: = 'tls_tracking_id ' | Chr (9) | ' fnn_ext' | Chr (9) | "path_id' | EOL;

fichier_en_sortie: = 'report_excel' |'. XLS;

owa_util.mime_header ("application/octet ', false");

HTP.p ('Content-Disposition: attachment; filename = "" | ") fichier_en_sortie |' « ') ;

owa_util.http_header_close;

HTP. PRN (output_header);

for r in)

Select tls_tracking_id, fnn_ext, DWD_DTOV_OUT_VW path_id

where nbn_loc_id = 'LOC000138413115. '

The order of tls_tracking_id LOOP)

HTP. PRN (r.tls_tracking_id

|| Chr (9) | r.fnn_ext

|| Chr (9) | r.path_id

|| EOL

);

END LOOP;

END;

Code2 used :

create or replace PACKAGE BODY IS pkg_excel_export

PROCEDURE excel_open (l_xml_body IN OUT NOCOPY CLOB) IS

BEGIN

l_xml_body: = ' <? XML version = "1.0" encoding = "ISO-8859-9"? > ' | Chr (10) |

"< workbook xmlns =" "urn: schemas-microsoft - com:office:spreadsheet" ' | "

Chr (10) |

""xmlns:o ="urn: schemas-microsoft-com ' ' |

Chr (10) |

"xmlns: x =" "urn: schemas-microsoft-com: excel" ' | "

Chr (10) |

""xmlns:ss ="urn: schemas-microsoft - com:office:spreadsheet" ' |

Chr (10) |

                        'xmlns:html=" http://www.w3.org/TR/REC-html40 ">' ||

Chr (10) |

' < ExcelWorkbook xmlns = "urn: schemas-microsoft-com: excel" > ' |

Chr (10) | ' < WindowHeight > 8580 < / WindowHeight > ' |

Chr (10) | ' < WindowWidth > 15180 < / WindowWidth > ' | Chr (10) |

' < WindowTopX > 120 < / WindowTopX > ' | Chr (10) |

' < WindowTopY > 45 < / WindowTopY > ' | Chr (10) |

' < ProtectStructure > false < / ProtectStructure > ' | Chr (10) |

' < ProtectWindows > false < / ProtectWindows > ' | Chr (10) |

' < / ExcelWorkbook > ' | Chr (10) | "< Styles > | Chr (10) |

'< ss:ID of style = 'Default' ss:Name 'Normal' = >' | Chr (10) |

"< ss:Vertical alignment = 'Bottom' / >" | " Chr (10) |

' < borders / > '. Chr (10) | ' < police / > '. Chr (10) |

' < Interior / > '. Chr (10) | ' < NumberFormat / > '. Chr (10) |

' < protection / > '. Chr (10) | "< / style > | Chr (10) |

'< ss:ID of style 's22' = >' | Chr (10) |

"< x: font family = ss"Swiss":"BOLD"="1"ss:Underline ="Single"/ >" | "

Chr (10) | "< / style > | Chr (10) | "< / style >";

END excel_open;

PROCEDURE excel_close (l_xml_body IN OUT NOCOPY CLOB) IS

BEGIN

l_xml_body: = l_xml_body | ' < / workbook > ';

END excel_close;

/ * Opens a worksheet in the Excel file. , You can open multiple worksheets. **/

PROCEDURE worksheet_open

(

l_xml_body IN OUT NOCOPY CLOB,

p_worksheetname in VARCHAR2

) IS

BEGIN

--

-Create the worksheet

--

l_xml_body: = l_xml_body | "' < worksheet ss:Name = ' ' | p_worksheetname |

"" > < table > ";"

END worksheet_open;

/ *Farm the worksheet in the Excel file.   **/

PROCEDURE worksheet_close (l_xml_body IN OUT NOCOPY CLOB) IS

BEGIN

l_xml_body: = l_xml_body | ' < / table > < / worksheet > ';

END worksheet_close;

/ *Opens the tag line * /

PROCEDURE row_open (l_xml_body IN OUT NOCOPY CLOB) IS

BEGIN

l_xml_body: = l_xml_body | "< row >."

END row_open;

/ *Farm the tag line * /.

PROCEDURE row_close (l_xml_body IN OUT NOCOPY CLOB) IS

BEGIN

l_xml_body: = l_xml_body | "< / row > | Chr (10);

END row_close;

/ *After the opening of the line, we can write something the first cell* /

PROCEDURE cell_write

(

l_xml_body IN OUT NOCOPY CLOB,

p_content in VARCHAR2

) IS

BEGIN

l_xml_body: = l_xml_body | ' < cell > < data ss:Type = "String" > ' |

p_content | ' < / data > < / cell > ';

END cell_write;

/ * If you use this package of APEX, you get to download the excel file. **/

PROCEDURE excel_get

(

l_xml_body IN OUT NOCOPY CLOB,

p_filename in VARCHAR2

) IS

XX BLOB;

make the NUMBER;

This NUMBER;

BC NUMBER.

LC NUMBER;

w NUMBER;

BEGIN

DBMS_LOB.CREATETEMPORARY (xx, TRUE);

make: = 1;

so: = 1;

BC: = dbms_lob.default_csid;

LC: = dbms_lob.default_lang_ctx;

w: = dbms_lob.no_warning;

DBMS_LOB.converttoblob (xx,

l_xml_body,

DBMS_LOB.lobmaxsize,

do,

Thus,.

British Colombia,

LC,

(w);

owa_util.mime_header ("application/octet ', FALSE");

-set the size so that the browser knows how to download

HTP.p ("Content-length: ' |") DBMS_LOB.GetLength (xx));

-the name of the file will be used by the browser if users only one save as

HTP.p ('Content-Disposition: attachment; filename = "" | ") p_filename |

'.xls ' | '"');

-close the headers

owa_util.http_header_close;

-Download the BLOB

wpg_docload.download_file (XX);

END excel_get;

END pkg_excel_export;

I know it's a bit long code, but to better understand please consider...

Thank you.

I did worked putting just one extra line in my l_xml_body in the XML (Code 2 used). Now my excel generates with cells type 'Text' and there are no left falling to zero. Also the columns display not scientific format as 2.3D + 12. Current recording shows without default formatting.

'

Tags: Database

Similar Questions

  • How to set default

    Hello

    I'm not able to find how to set default to hide the windows (F4) layer on the very good on the screen, when I open the document.

    Thanks for your advice

    File - properties - view initial - Navigation tab.

  • How to set default Photoshop in 10 House windows?

    How to set default Photoshop in 10 House windows?

    Please make Photoshop Your Default Image Editor in Windows 10

    Let us know if this helps

    Kind regards

    Assani

  • How to set an excellent type of cell as a text instead of general using owa_util?

    Hello

    I'm generating a csv file by using the following code. But when I open the file using excel, it excludes from 0 and also converts the cells in scientific format. I'm genrating the file using values from database table and I want the file exactly with the same values. I browsed a few forums and found that if I could convert the type of cell from the general text it will keep the values exactly how he got. I have no idea how to do that.

    Please notify.

    Code:

    Declare

    output_header varchar2 (4000);

    fichier_en_sortie VARCHAR2 (255);

    Varchar2 (2) EOL: = Chr (13) | Chr (10);

    BEGIN

    output_header: = q'~ ADBOR_ID, ID of path ~' | EOL;

    fichier_en_sortie: = 'report ' | ". CSV';

    owa_util.mime_header ("application/octet ', false");

    HTP.p ('Content-Disposition: attachment; filename = "" | ") fichier_en_sortie |' « ') ;

    owa_util.http_header_close;

    HTP. PRN (output_header);

    for r in)

    Select ADBOR_ID, from my_table Path_ID) LOOP

    HTP. PRN (r.ADBOR_ID|) «, » || r.Path_ID | EOL);

    END LOOP;

    END;

    -Compare the results-

    Entry effective from my_table from database. ADBOR_ID: 0296221924

    Output in csv (default cell type General): 296221924

    It's the scientific format also round the number like this:

    Real From my_table of database entry. Path_ID: 5878778827826

    Output to csv()default cell type General(): 5.87878E + 12

    Just prepend the numeric values with an apostrophe.

    Test in a file and when you load the file in excel, you will see that it is treated as text.

  • How to set default things?

    Hello

    How can I set the following as default value for a document?

    Dash:

    Right: 0.76

    Left: 0.76

    Topic:

    CapsLock.

    Font size:

    Topic: 11

    Body text: 10.5

    Notes: 9.5


    Spacing between lines:

    Attack: pkt 3

    Font type:

    Overskrift: Arial

    Brodtekst: Calibri

    So it is clear, if you set default values with no documents open, they will become the defaults for all new documents in the future.

    To set the default settings for a single document, do with this document, open it.

    Specifically to your desired default values list, you will need several paragraph styles to apply different settings for headers, body, notes, etc. When you type text, InDesign does not know your intention; You should apply styles to paragraph according to your wishes.

  • How to set a cell stroke?

    Hi experts

    I want to change the type of null cells lines in docs open.

    could someone please to tell me how to set Docs [i] .everyItem ().stories.everyItem ().tables.everyItem ().cells.everyItem ();?

    my script as:

    var Docs = app.documents.

    for (var i = Docs.length - 1; i > = 0; i--) {}

    var s = Docs [i] .everyItem ().stories.everyItem ().tables.everyItem ().cells.everyItem ();

    s.topEdgeStrokeType = null;

    s.bottomEdgeStrokeType = null;

    s.rightEdgeStrokeType = null;

    s.leftEdgeStrokeType = null;

    }

    What is wrong with him?

    Respect of

    John

    I deleted my previous post because it was false. The error in the code is Docs [i] .everyItem () - you can do that. Instead, follow these steps:

    s = app.documents.everyItem().stories.everyItem().tables.everyItem().cells.everyItem();
    s.topEdgeStrokeType = null;
    s.bottomEdgeStrokeType = null;
    s.rightEdgeStrokeType = null;
    s.leftEdgeStrokeType = null;
    

    P.

  • How to set default COPY for HP Officejet 6500 has more quality DRAFT?

    How can I set default COPY quality to the PROJECT for HP Officejet 6500 has more?

    Hello

    Press on copy on the front panel of the printer, then press the settings button.

    Quality faucet and quick selection / project.

    Press on set as the new default settings, and then click Yes to confirm the changes.

    Later draft quality will be used for the copy unless any other quality is selected.

    Kind regards

    Shlomi

  • How to set the display format for datetime field in a page jspx

    Hi, jdev 11.1.2.3
    have an EO/VO field set to DateTime format and can see the right screen in the Oracle ADF Model tester.
    but only displayed in the format of Date had been set to "javax.faces.DateTime" for the attributes property for the field palette converter.

    What should I do?
    Thank you.

    did you mean like this?


    Type = "both" / >

  • Under Format/paragraph - how I set default text?

    Whenever I create a message to send, after the first line of text, hit enter to jump a line, which is the double spaces. I then go to Format/paragraph and change 'Paragraph' in 'body text '. I want to "Body text" and single-spaced to be the default. Thank you.

    There is a setting for this in the dialog box Options (Preferences) of Thunderbird. In this dialog box, click the icon for the Composition, there is a checkbox in the HTML section for what the Enter key (create paragraph vs create line break).

    Some users have struggled to Open the dialog box Options (Preferences) because the menus vary. Please try here:

    • button '3-bar' menu also known as the Application button:

      • Windows: Options > Options
      • Mac and Linux: Preferences > Preferences
    • Class menu bar:

      • Windows: Tools > Options - tap the Alt key or press F10 to activate the menu bar if you don't keep it displays all the time
      • Mac: Thunderbird > Preferences
      • Linux: Edit > Preferences

    Can find you it? What is fix?

  • How to set default print mode instead of fax

    When I click on print from a Web page my hp officejet pro 8500 (A909a model) default Telec.   How can I set the default it goes always straight to the printing mode?  Any help appreciated.  Thank you

    Hello

    I understand it, please download HP print and scan doctor below link to set the default printer. You can also have this practice if you encounter printing problems in the future.

    http://h10025.www1.HP.com/ewfrf/wc/softwareDownloadIndex?softwareitem=OJ-106151-2&cc=us&DLC=en&LC=en&OS=228&product=3752456&sw_lang=

  • How to set up to receive texts

    has got a new iphone 5 s, but text messaging is blocked - how to I unlock?

    If you can use iMessage, then it is not the phone

    Text messaging is a feature of carrier - contact your carrier and ask them to check if the SMS are set on your account

    (1204)

  • How to set the size of text with the report generator

    Hello.

    I'm trying to set the size of the text with the report generator, but I find that I can't do this. Here is an example of the code that I use. Can someone tell me what I'm doing wrong please?

    Thank you, Alec

    I was generation from a word template.

    I hacked my version of the Toolbox to give me maunal indicator control "model? He had obtained his permenatly self stuck on "T". I exposed this flag outside the API, so I can control under certain weather conditions I may or may not use the model police.

    Does anyone know how to use this toolkit, or I did the right thing?

    Cheers, Alec

  • How to set default printing shortcut or change standard ones

    I have a LaserJet 2420d with the PCL 5 driver.  Whenever I print, it uses the default paper shortcut that is "General printing every day."  This built-in shortcut specifies a type of "Pre-printed", so the printer breaks waiting for pre-printed paper inserted until I press the check mark button.

    I can create a custom form that has solved the problem, but I don't know how to make my custom form by default for the printer.  Furthermore, if I could change the type of paper for the 'General everyday printing' and save it, it would solve the problem.

    So how set my default paper form shortcut or change the standard one?

    Furthermore, the who Devil set by default to use paper pre-printed paper?

    Open your printers and Faxes folder, right click on the printer icon and select Printing Options. and any changes made here will be defined as a default value.

  • How to set different date formats for different metadata fields?

    Hello

    Can I set different date for different fields of metadata formats? Standard Date format has a seconds. But I metadata fields, where I need to only show the date.

    I tried to use the rules and side effects. My code is: $xMyDate = formatDateOnly (xMyDate) $ >. But it does not work.

    Please how can I do?

    Thank you

    Martin

    Hi Laurent,.

    Large. This works. Good definition is:<$setValue("DOC_INFO","xDatumUkonceniRizeni",formatDateOnly(xDatumUkonceniRizeni))$>

    M.

  • ADF: How to set default values for the attributes of each Insert online?

    Hello

    I am new to the ADF. I'm developing a simple Application from merger where a column of af: table has to be displayed with the user name (default) on each insertion.

    I tried using below EL:

    < af:inputText value = "#{null == row.bindings.SalesPeople.inputValue?" "{userBean.strUserName: row.bindings.SalesPeople.inputValue}"...

    And I am able to display the logged in user name by default on the side of the user interface, but the name of the user isn't getting recorded in the database.

    The action that I used to insert a new line is "CreateInsert".

    < af:commandButton text = 'Add new record' id = "cb1" actionListener = "#{bindings." CreateInsert.execute}"partialSubmit ="true"/ >

    Please help me how to solve this problem...

    Thank you

    Alexander

    Thank you all,

    I was able to solve this problem in action appellant and here is the code snippet

    actionListener = "#{bindings." CreateInsert.execute}"action =" #{testBean.getSalesPeople} ' "

    partialSubmit = "true" / >

    ----

    public void getSalesPeople() {}

        Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();
        UserInfoBean userBean = (UserInfoBean) JSFUtils.getManagedBeanValue ("userBean");
        DCIteratorBinding quoteIter = bindings.findIteratorBinding("SalesQuoteView1Iterator");
        RowSetIterator quoteRSIter = quoteIter.getRowSetIterator ();
        RowKeySet rowKeySet = m_SalesQuoteTbl.getSelectedRowKeys ();
        If (rowKeySet! = null & rowKeySet.size () > 0) {}
            Iterator rksIterator = rowKeySet.iterator ();
            The list rowKey = (List) rksIterator.next ();
            Key = (Key) rowKey.get (0);
            Line currentRow = quoteRSIter.getRow (key);
            currentRow.setAttribute ("Sales", userBean.getStrUserName ());
    }

    Appreciate your point of view on my solution.

    Thank you

    Alexandre Ali

Maybe you are looking for

  • tried to update itunes and it keeps crashing after update

    Tried to update itunes and has not worked since, every time I try to open itunes, I just get the same message "iTunes has stopped working" here is the copy and paste the details of the problem, I use windows 7 64-bit Signature of the problem: Problem

  • 15-ab236nl Pavilion: Pavilion 15-ab236nl install an SSD

    Hello I am interested in buying this laptop Pavilion 15-ab236nl AFAIK, there is no option for a second HARD drive, so if I change the default HARD drive with an SSD in my choice would that work? (which means I'm able to reinstall Win10 etc..) or rath

  • Formula node and operations table

    Hello I try to use the node formula to subtract the previous mandate of the current period (or the next term less the current term), but I can't figure out how use array index to do. I have something in the sense of z_array [i + 1] - z_array [i], but

  • Frustrate the pop up and possible virus

    Something keeps popping up saying "error: catch after unconditional capture" over and over again on every page I open with Mozilla Firefox. It says [JavaScript Application] above. I can't find any program for this on my laptop and I've done a scan, b

  • About what will be Windows XP not supported by Microsoft (not updated)?

    When will be Windows XP not supported by Microsoft (not updated)?