BusinessObjects Board

Export as csv or txt file using macro

Text does not support formatting. You’ll get the data from the report, but the positioning will be limited, at best.

Read them again. :wink: When you see a call to ConvertTo, it is being applied to the cube (data provider). When you see a call to ExportAsText or ExportAsPDF that is being applied to the report (or document, if available).

I understand; it can be confusing. The menu item to save the data provider (cube) is Export, while the menu item to save a report as text is Save As. But the VBA equivalents are:

Export => ConvertTo()
Save As => ExportAs{Type}
… where {Type} can be Text, RTF, PDF, or HTML.

Dave


Dave Rathbun :us: (BOB member since 2002-06-06)

The bottom line is that ‘Export’ or ‘Save As’
{where the target is a text file} does not result in correct
formatting of the report.

I have been able to retain the format of the report by
the earlier steps I recommended.

Using VBA, Export the report into HTML format. Open HTML
file from MS Excel and save from Excel to text. I will post
the code shortly.

Thanks


kunal (BOB member since 2003-03-17)

Hi

I am trying out for exporting to Excel with Different Sheet. Ie

  1. I have to get a excel file name
  2. If it is new, then create excel file and export te data to the given Sheet name.
  3. If it is already exist, then create one more sheet(taken as input) and export the data into that sheet and save it.

I have a posting(exactly the previous posting of this one.) and i am getting error subscript out of range when

given like Sheet(inputssheetfilename). move _before Line.

Can anybody give solution.


meetrln (BOB member since 2002-12-03)

You may want to take a look at this thread.


Cindy Clayton :us: (BOB member since 2002-06-11)

Hi cindy

seems very interesting add-in. unfortunately, when i tried to reach out Avaski’s donwload page, its stopped me saying unauthorized entry kind of IE message.

But i am desparately looking forward a kind of code. hope it wold contains creating New worksheet in already existing excel file.

Can you send this add-in to me at rlnsimha2000@yahoo.com

sorry for the inconvenience.


meetrln (BOB member since 2002-12-03)

When I used it it asked me whether I wanted to export the entire document and when I said ‘yes’ it put each report in a separate tab of the same spreadsheet. That sounds like maybe it would be helpful to you. Try the link in this thread.

The link is…

http://www.avaksi.com/assets/others/Conversions.rea


Cindy Clayton :us: (BOB member since 2002-06-11)

Is there a out of box solution for converting Business Objects reports to text files retaing exact formatting of all the tables.? Save as txt distorts the formatting. I am looking at some solution which will convert it to proper text file. Any solution which uses any external software also is fine.


JaiGupta (BOB member since 2002-09-12)

Try www.infosol.com. I think they may have something.


Cindy Clayton :us: (BOB member since 2002-06-11)

Text files don’t have formatting. If you need formatting, you can try RTF instead. Or - as someone else in this topic mentioned - save as HTML and then process via some other application.

But text files are just that, letters and numbers. Spacing / formatting / layout is all lost.

Dave


Dave Rathbun :us: (BOB member since 2002-06-06)

But there has to be some way by which I can format these unformatted files to the required format. Excel has row limitaions. Other products like Brio and Crystal reports retain the format. Any scripting language like awk can be used or not.


JaiGupta (BOB member since 2002-09-12)

Hi, Dave:

I have one question about this code, export the report (raw data) as a CSV file by using the convertto() function.

There is one column, which has commas in it. When I opened the report in Notepad, this column was separated as multiple columns due to the comma inside the column. Users want this column will be inside a double quote. I created a variable in the report, using char(34), but it didn’t work. I wonder if I have to define the variable in the universe, then it will work. I haven’t tried that yet.

Thanks very much for your help.

Lilly


Lilly J (BOB member since 2002-08-22)

How can I get rid of the headers and simply export the data?


Cindy Clayton :us: (BOB member since 2002-06-11)

Remove the headings from the report or have a second tab just for exporting without headings. Or did I misunderstand your question?
Never mind, you want to remove the headings when you export from the d/p not the report. :crazy_face:


Michele Pinti (BOB member since 2002-06-17)

Yes! That’s the dilemma Michele.

Alternatively, I know that I can’t export the report per se as .csv but could I use some creative technique to concat a ‘,’ with the data…

I still can’t get rid of those pesky tab delimiters though :confused:. I may be asking the impossible. At this point I’m making a report with Essbase, Oracle and various and sundry other data providers so if I have to give them tabs, that may be what they have to accept. I’m already working a miracle here :wink:


Cindy Clayton :us: (BOB member since 2002-06-11)

Hi Dave
The above macro works fine in version 5 FC.
But in Version 6 FC it gives the following error: " Compile error :Type Mismatch " at the last line boDP.ConvertTo.
Any ideas why its not working in Version 6 FC.
I tried without assigning it to intReturntCode . Still it didn’t work.
Thanks for your time
Veera


BigV :australia: (BOB member since 2003-12-04)

Hi
I fixed it.
The code looks like below in version 6.
Dim bodoc As busobj.Document
Dim boDP As busobj.DataProvider

Dim strOutputFileName As String
Dim intReturnCode As String
Set bodoc = ActiveDocument
Set boDP = bodoc.DataProviders.Item(1)

strOutputFileName = "C:\CSVOutput.csv"

Call boDP.ConvertTo(boExpAsciiCSV, 1, strOutputFileName)


BigV :australia: (BOB member since 2003-12-04)

[quote=“Cindy Clayton”]

Hello:

We just copied the whole repository of v5 to v6.5. When I tested reports, those with macros give me some error message. I have one report using this piece of code, which worked perfectly in v5.1.5, but it keeps saying “Type Mismatch” for the last line: boDP.ConverTo.

I wonder if anyone has come across to this.

Thanks very much.

Lilly


Lilly J (BOB member since 2002-08-22)

I don’t have an explanation for why it works in v5, other than it was a sloppy implementation in v5 that was fixed in v6. The ConvertTo method is not documented as a function, which would be necessary to bring back a return code. Just replace “intReturnCode =” with “Call” in that one line, and you should be good to go.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

This works. Thanks very much.


Lilly J (BOB member since 2002-08-22)

Great! If you think this thread was helpful, consider giving it a “point” … the thumbs-up :+1: icon at the lower right of each post. Someday, we’ll use the “points” information in BOB’s search functionality.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)