Add a "%" symbol with Excel Interop
Hello folks!
How do I programmatically put a "%" symbol to a column in the Excel chart. I am using Excel Interop library.
Any advice will be appreciated!
I am working on wpf desktop application in which I am using C# 4.0 and MVVM design pattern. The app generates several Excel reports and I am using Microsoft.Office.Interop.Excel.dll library to export data from wpf app to excel file. I have found that the
Microsoft.Office.Interop.Excel.dll library is a good choice for dealing with Excel files. Below is the code I am using to generate the chart above.
private void CreateChart(string[] xValues, double[] yValues)
var xlCharts = (Excel.ChartObjects)_sheet.ChartObjects(Type.Missing);
var myChart = (Excel.ChartObject)xlCharts.Add(48, 241, 750, 400);
var chartPage = myChart.Chart;
chartPage.HasLegend = false;
chartPage.ChartType = Excel.XlChartType.xlColumnClustered;
chartPage.ChartStyle = 4;
var seriesCollection = chartPage.SeriesCollection();
var series1 = seriesCollection.NewSeries();
series1.Name = MetroNew.Localization.Properties.Resources.ReportFractionTitle;
series1.XValues = xValues;
series1.Values = yValues;
var vertAxis = (Axis)chartPage.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary);
vertAxis.HasMajorGridlines = true;
vertAxis.MaximumScaleIsAuto = false;
vertAxis.MaximumScale = 100;
vertAxis.MinimumScaleIsAuto = false;
vertAxis.MinimumScale = 0;
var pointsCount = series1.Points().Count;
Color color;
for (int i = 1; i <= pointsCount; i++)
if (i <= 50)
color = Color.FromName(i.GetColorByName());
else
var rnd = new Random();
int index = rnd.Next(1, 50);
color = Color.FromName(i.GetColorByName());
series1.Points(i).Interior.Color = color;
var axis = (Axis)chartPage.Axes(
Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary);
axis.HasTitle = true;
axis.AxisTitle.Text = MetroNew.Localization.Properties.Resources.ReportFractionContentTitle;
series1.ApplyDataLabels(
Excel.XlDataLabelsType.xlDataLabelsShowLabel,
true, true, true, false, false, true, true,
true, true);
Similar Messages
-
Essbase excel add in conflicts with Excel 2007
Has anyone encountered issues when using the essbase excel add-in on Excel 2007?
Is there a fix or newer add-in version?user3055639 wrote:
thanks
I will be installing essbase version 11 shortly, I assume this problem will be fixed in this release?Not sure.
Extracts from Oracle Essbase Release 11.1.1.3 readme file > Known Issues:
+Spreadsheet Add-in: Spreadsheet Add-in does not support worksheet sizes greater than 65,536 rows by 256 columns. [7486542]+
+Spreadsheet Add-in: With Excel 2007 on Windows XP or Windows Vista, running a VB script to log into a spreadsheet results in slow connection times. [7035038]+
" -
Does Hyperion/Essbase add-in works with Excel 2010?
Is this possibility and is performance enhanced/reduced?
Thanks.Yep, the Certification Matrix isn't completely clear on this point but a pretty good authority (Matt Milella) says a definite 'No' for 64-bit with the Add-In: http://essbaselabs.blogspot.com/2012/04/smart-view-64-bit-office-support.html
For users currently using the 'legacy' Add-In with 2003, the main 'pain point' is going to be moving to the Add-Ins ribbon, and the corresponding additional clicks / additional keystroke in every shortcut. Current 2007 users will have dealt with this transition already. -
Excel interop. error with Visual Studio 2012
I am using a stand alone and not a server loaded with VS and office 10, I have done all the interop and importing name space and from my experience that should not be a problem.
Just help, how is this finally resolved, have you done an article on it?
Retrieving the COM class factory for component with CLSID {00024500-000-000-C00000000046}
failed due to the following error:
80004023 A Microsoft software installer error was encountered.(exception from HRESULT:0x80004023)
Please helpHi,
>>The reason this is the right forum is that we are talking about preserving COM and hooking up these libraries
into the managed environment using Interoperation.
I will clarify the topic of this forum. This forum is discussion questions about visual studio extension such as the VSPackage, Add-in and so on. And according to your second reply
"By the way am getting this error while sending data from VS 2012 to Excel"
and your original post, that forum is the correct one. General Office Development forum is for office
developer or related with office development. Your problem is related with excel, in other word, Microsoft office.
And the
General
Office Development forum is for general Office Developer discussions and questions that are either non-application specific
and/or are not specific to one of the product specific forums in this category.
I have consulted the engineer there to ensure it is a case there.
Please feel free to let me know if I misunderstand you.
Thank you for your understanding!
Best regards,
Sunny -
Known issues for OBIEE Office Add in with Excel 2007?
Hi,
Does anybody know if there are issues for the office add-in with Office 2007?
i'm playing around a little bit to see how it works, but it seems that Excel interferes with the layout.
I do get different grafs and also i tried the tutorial with the excel template and my changes come only partly through.
Thanks
SandraHi Sandra,
Were you able to use OBIEE Office Add in with Excel 2007? I am planning to look at this compatibility. I am looking here to seeif anyone found issues with this setup..
Thanks,
Bharat -
Essbase Add-In v6.2 not working with Excel 97
I am running client Windows NT 4.0sp6 with Excel 97 and just tried to upgrade the Essbase Excel Add-In to version 6.2.1 from 6.0. The add-in appears to work fine for all Essbase functions except Essbase-Options. When I select Essbase-Options, I immediately get an Excel.exe application error as follows:The instruction at "0x01e412b5" referenced memory at "0x0000003c". The memory could not be read.My upgraded v6.2.1 Application manager appears to run fine. Anybody got any ideas?? According to Hyperion documentation, v6.2.1 works with Excel 97.
-
Does anyone know a safe free download of E13b font/symbols compatible with Excel for Mac?
Does anyone know of a safe, free download of the symbol/font E13b to use with Excel for Mac? E13b are the numbers and symbols at the bottom of checks and deposit slips. Thanks!
Ask on the Microsoft Mac form since their Software that you're using
http://answers.microsoft.com/en-us/mac -
Essbase 7 add-in with Excel 2007
Hi,
We are using Essbase Spreadsheet services 7.1.3 (EssbaseWebService) in Excel 2007 and we are facing an issue with the zoom-in function. The zoom-in retrieval time is a lot more time consuming than with Excel 2003.
Do someone ever faced the same issue ?
Thanks !
MathieuHi Mathieu,
As per support matrix documentation, Essbase 7.1.3 is not supported with Excel 2007.
You may have to upgrade to client version 7.1.6.7 which supports Excel 2007.
Thanks,
Raja -
MDS Excel add-in with Excel online
Hi,
I would like to explore the possibility to use excel online (excel services in SharePoint) to administer MDS-data using the Excel add-in. Since there is a need to reach the Master Data menu options in the Excel sheets for the simple reason of publishing
I have not yet found a way to make this possible since the SharePoint excel online menu options are restricted.
Does anyone have any experience of using Excel MDS add-in through SharePoint Excel SErvices?
...or a similar problem allowing Excel online to show (and use) the menu bar?
(Would like to avoid rolling out Excel add-in on all clients...)
Best Regards,
PerAny suggestions for Per?
Thanks!
Ed Price, Azure & Power BI Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it! -
Hi there! We have a proposal template in Excel that, in my code, I export to a JPG and attach to an e-mail. I've been using Excel Interop for this. Since we've upgraded to .NET 4.5 it isn't working. I understand there's been some
changes. I'll admit I don't understand this stuff. I grabbed some code off the internet, modified it and have been using it.
The thing is, the code is working on my development machine, but not on a couple of my test machines once I compile it and deploy. I don't quite know why. The Interop assemblies are on all the machines. Here's my code:
Sub ExportProposalToJPG(ByVal path As String)
'' See if excel is open, if so, need to close
Dim excelCount As Integer = 0
For Each myProcess As Process In System.Diagnostics.Process.GetProcesses
If UCase(Mid$(myProcess.ProcessName, 1, 5)) = "EXCEL" Then
myProcess.Kill()
excelCount += 1
End If
Next
MsgBox(Str(excelCount) + " instances of Excel closed.")
If My.Computer.FileSystem.FileExists(Environ("Temp") & "\proposal.jpg") Then
My.Computer.FileSystem.DeleteFile(Environ("Temp") & "\proposal.jpg")
End If
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim MyChart As Microsoft.Office.Interop.Excel.Chart
Dim objPict As Object
Dim RgCopy As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
excel.DisplayAlerts = False
Dim myFilename As String
myFilename = System.IO.Path.GetDirectoryName(path) & "\" & "~$" & System.IO.Path.GetFileName(path)
If My.Computer.FileSystem.FileExists(myFilename) Then
My.Computer.FileSystem.DeleteFile(myFilename)
End If
wb = excel.Workbooks.Open(path, 2, True)
'' CHANGE THIS BACK TO FALSE!!!
excel.Visible = False
wb.Activate()
ws = wb.ActiveSheet
'RgCopy = Application.InputBox("Select the range to copy / Saveas", "Selection Save", Selection.Address, Type:=8)
RgCopy = excel.Range("A1", "K63")
RgCopy.CopyPicture(XlPictureAppearance.xlScreen, XlCopyPictureFormat.xlBitmap)
excel.ActiveSheet.PasteSpecial(Format:="Bitmap")
objPict = excel.Selection
With objPict
.CopyPicture(1, 1) ':=1
MyChart = excel.ActiveSheet.ChartObjects.Add(1, 1, .Width + 8, .Height + 8).Chart
MyChart.SetSourceData(RgCopy)
End With
With MyChart
.Paste()
.Export(Environ("Temp") & "\proposal.jpg")
.Parent.Delete()
End With
MyChart = Nothing
wb.Close(False)
MsgBox("Proposal Exported.")
Exit Sub
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel)
RgCopy = Nothing
objPict = Nothing
MyChart = Nothing
ws = Nothing
wb = Nothing
Try
excel.Quit()
Catch
End Try
excel = Nothing
Catch
MsgBox(Err.Description)
End Try
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
End Sub
Here is the error I get:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Range.CopyPicture(XlPictureAppearance Appearance, XlCopyPictureFormat Format)
at EwingDataApplication.Utilities.ExportProposalToJPG(String path)
at EwingDataApplication.SendEmail.setPath(String path)
at EwingDataApplication.EditSignWorkOrder.Button8_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18444 built by: FX451RTMGDR
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
EwingDataApplication
Assembly Version: 1.0.0.39
Win32 Version: 1.0.0.39
CodeBase: file:///C:/Users/tewing.EWINGGRAPHICS/AppData/Local/Apps/2.0/XCDV80Z3.63R/6NBNX34M.P4H/ewin..tion_9b22d5a3b42c0366_0001.0000_74bc74471f410f1b/EwingDataApplication.exe
Microsoft.VisualBasic
Assembly Version: 10.0.0.0
Win32 Version: 11.0.50938.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34238 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
System.Runtime.Remoting
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34245 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34234 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
Ewing
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/tewing.EWINGGRAPHICS/AppData/Local/Apps/2.0/XCDV80Z3.63R/6NBNX34M.P4H/ewin..tion_9b22d5a3b42c0366_0001.0000_74bc74471f410f1b/Ewing.DLL
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
Npgsql
Assembly Version: 2.2.0.0
Win32 Version: 2.2.0
CodeBase: file:///C:/Users/tewing.EWINGGRAPHICS/AppData/Local/Apps/2.0/XCDV80Z3.63R/6NBNX34M.P4H/ewin..tion_9b22d5a3b42c0366_0001.0000_74bc74471f410f1b/Npgsql.DLL
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
Mono.Security
Assembly Version: 4.0.0.0
Win32 Version: 4.0.0.0
CodeBase: file:///C:/Users/tewing.EWINGGRAPHICS/AppData/Local/Apps/2.0/XCDV80Z3.63R/6NBNX34M.P4H/ewin..tion_9b22d5a3b42c0366_0001.0000_74bc74471f410f1b/Mono.Security.DLL
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
Microsoft.Office.Interop.Excel
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4675.1003
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
office
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4675.1002
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Is this enough info to get some help? Am I going in the wrong direction? Is Interop not the way to go on this? I want to save an Excel sheet from my database, export it to an image, and attach it to my work order. This worked before
we upgraded our server.
Thanks!
Dave Sharpe
Ewing GraphicsWithout really looking at the all of the error information apparently your non development machines must be different in some fashion from your development machine if you've installed your app onto your development machine and it works without being run
from Visual Studio.
Just because some .Dlls are on all the machines does not mean they are all the same .Dll's with regard to version or other properties.
Are all the machines x86 or x64? Is the development machine running x86 or x64 Office? Which version of Office? Is that same version of office (x86 or x64) installed on the non development machines?
It's possible that using the references on your development machine to install with your app would resolve issues. To do that see this thread
Line and Rectangle shapes in VS 2013 that provides instruction on how to make your app provide copies of all referenced assemblies so they can be included with the app when it gets installed on a system.
Also see
.Net 4.5 - How the Runtime Locates Assemblies.
And obviously the non development machines have .Net 4.5 installed on them as that is what your app is compiled to.
La vida loca -
C# - Excel Interop - Print Areas - French
Hi,
I'm writing a C# application that manipulates an Excel sheet. That Excel sheet has Print Areas that has to remain intact.
The problem comes from the Office language (French). When I open the Excel Workbook with the Workbooks.Open method, the Print Areas (Zone_d_impression in French Excel) gets renamed to Print_Area. Excel can no longer read the Print Areas once they have been
renamed.
This happens as you open the Workbook, even before saving. If Excel is launched with Visbility enabled, the Print Areas are not work and if you close without saving and open the file manually, the Print Areas are still there. However, if you save the Excel
opened with the interop, the Print Areas are gone even if opened manually afterwards.
Any tips?Hi,
I'm not exactly sure a screenshot of what exactly could help you. The code? The excel print area names?
I think it's more of a explanable by text issue then screenshot so if you need more details on the issue or my english made my original post misunderstood, please let me know. I'll try to clarify it.
-Edit-
I'll try to explain it a little more in a "Scheme" form:
Description of the Excel workbook :
There is 4 sheets, 3 display and 1 hidden that contains data. The 3 display pages has formulas to concatenate data from the 4th hidden sheet to display it in a legal format. All the cells with formulas or layout in the display sheet are locked and only one
section (range) plus a few cells are filled manually. There can be added rows in the "section" which kills any possibility of setting the print area automatically with a range, which leads me to setting the area in the initial model.
Steps:
-Excel form created using French Excel 2007.
-C# Winform application manages a SQL database (not really important for this issue)
-User clicks on the "Generate" button when all the data in the winform is filled.
-Application checks of there Excel sheet already exists and if not, copys the model sheet.
-Application opens the already in place sheet or the fresh copy. -Print Areas are lost here-
-Application saves the sheet. -Sheet saved with the lost sheets-
My observations:
The Print areas are lost BEFORE SAVING. If the application runs the Excel application with Visibility set to True, and add a break to stop before it set data or save or close the workbook, you already lost them, but if you close the excel without saving
(or kill the application) and open the workbook manually, the Print Areas are still there. The problem happens when the application opens the workbook and not when it manipulates or saves it.
Now the Print Areas are not really "Lost" or "Deleted" or "Broken". The problem is that when opening a workbook with the Excel Interop, it seems to be renaming the Print Areas from French "Zone_d_impression" (remember the Excel used is a French 2007 version)
to "Print_Area". However, the Excel application controlled by the interop is a French version as well, so I have no clue why the interop acts as it needs to adapt the workbook in english if the application it controls is in french. After renaming the Print
Areas to english, they simply appears as "Named Ranges" in excel and does not affect the printing. -
Issue in sending e mails with Excel attachment
Hi,
I am facing an issue with one function module - SO_DOCUMENT_SEND_API1. We were using this for sending mails to diff destination with excel sheet attachment contains sales data. This system has been migrated from 4.5B to ECC 5. Now this process is not working like the old one and the excel attachment is not properly formatted. All the data is being written into one cell of excel sheet and it seems only one line is present in output and is corrupted.
Can you please let me know what might be the issue here, any alternate option available or something to be modified in new version with this function module?
Thanks in advance,
UllasHi Ullas,
check this once.
REPORT ZLAXMI_ALVMAIL4 .
TABLES: EKKO.
PARAMETERS: P_EMAIL TYPE SOMLRECI1-RECEIVER
DEFAULT '[email protected]'.
TYPES: BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
END OF T_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,
WA_EKPO TYPE T_EKPO.
TYPES: BEGIN OF T_CHAREKPO,
EBELN(10) TYPE C,
EBELP(5) TYPE C,
AEDAT(8) TYPE C,
MATNR(18) TYPE C,
END OF T_CHAREKPO.
DATA: WA_CHAREKPO TYPE T_CHAREKPO.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM DATA_RETRIEVAL.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Example .xls documnet attachment'
'XLS'
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP AEDAT MATNR
UP TO 10 ROWS
FROM EKPO
INTO TABLE IT_EKPO.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_EKPO INTO WA_CHAREKPO.
CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
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.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM INITIATE_MAIL_EXECUTE_PROGRAM.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
FORM POPULATE_EMAIL_MESSAGE_BODY.
REFRESH IT_MESSAGE.
IT_MESSAGE = 'Please find attached a list test ekpo records'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
Regards,
Laxmi. -
Problem in excel format while sending mail with excel attachment.
Hi Gurus ,
I am sending a email with Excel attachment using FM SO_DOCUMENT_SEND_API1 or SO_NEW_DOCUMENT_ATT_SEND_API1.
I am able to send a mail with excel attachment with a piece of code which I got from SDN itself.
But the problem is when I am trying to open the attachment, <b>A pop up comes which says that it is not in recognizable format. Would you like to open it?
and several other lines of caution.</b>
When i choose to open it, i get the correct data in one excel sheet. Certain vertical lines of the excel sheet is missing. <b>But no data is missing. </b>
I am attaching the code below. Can any one please tell me where is the problem in this code ?
Thanx in advance
types: begin of t_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
meins type mara-meins,
end of t_mara.
data: gt_mara type table of t_mara,
wa_mara like line of gt_mara,
it_packing_list type table of SOPCKLSTI1,
wa_packing_list like line of it_packing_list,
it_receivers type table of SOMLRECI1,
wa_receivers like line of it_receivers,
it_mailbody type table of SOLISTI1,
wa_mailbody like line of it_mailbody,
it_attachment type table of SOLISTI1,
wa_attachment like line of it_attachment.
data: la_doc type SODOCCHGI1.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
* get material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
* Populate the subject/generic message attributes
la_doc-obj_langu = sy-langu.
la_doc-obj_descr = 'Material Details' . "Mail Header
la_doc-sensitivty = 'F'.
la_doc-doc_size = 1.
* Add the recipients email address
CLEAR wa_receivers.
REFRESH it_receivers.
wa_receivers-receiver = 'PCSDEVL'.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers to it_receivers.
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody to it_mailbody.
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
ENDLOOP.
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list to it_packing_list.
* Create attachment notification
wa_packing_list-transf_bin = 'X'.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
wa_packing_list-obj_descr = ' '.
concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
separated by space.
wa_packing_list-doc_size = wa_packing_list-body_num * 255.
APPEND wa_packing_list to it_packing_list.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = la_doc
PUT_IN_OUTBOX = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
tables
packing_list = it_packing_list
* OBJECT_HEADER =
CONTENTS_BIN = it_attachment
CONTENTS_TXT = it_mailbody
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receivers
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.REPORT Zex5 LINE-SIZE 255 LINE-COUNT 255 .
class CL_ABAP_CHAR_UTILITIES definition load. "-->
TABLES : vbap.
SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
DATA : BEGIN OF itab OCCURS 1,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
END OF itab.
parameters : p_email like somlreci1-receiver
DATA: tlines type i.
DATA: itmessage LIKE solisti1 OCCURS 1 WITH HEADER LINE. "Ok
DATA: itattach LIKE solisti1 OCCURS 2 WITH HEADER LINE. "Ok
DATA: itpacklist LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: itreclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
data: itattachment like solisti1 OCCURS 2 WITH HEADER LINE.
start-of-selection.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE itab
WHERE vbeln IN s_vbeln.
**Make the internal table data to be compatible in excel format .
PERFORM BUILD_XLS_FORMAT.
**Populate message of body text.
clear itmessage.
refresh itmessage.
itmessage = 'Please find attached Excel file'.
append itmessage.
PERFORM send_mail_as_xls_attachment tables itmessage
itattach
using p_email 'Excel Attachment' 'TXT' " 'XLS'
using p_email 'TEXT Attachment' 'TXT' " 'XLS'
'TestFileName'
'SalesOrders' .
*& Form BUILD_XLS_FORMAT
text
--> p1 text
<-- p2 text
form BUILD_XLS_FORMAT.
previosuly we were using for unicode ..now replaced
**Declare constants for the spacing .
*Constants : con1 type x value '0D',
con2 type x value '09'.
Constants : con1 type c
value CL_ABAP_CHAR_UTILITIES=>CR_LF,
con2 type c
value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
**For the Header descriptions.
Concatenate 'SalesORdNo'
'Item'
'Materialno' into itattach separated by con2.
Concatenate con1 itattach into itattach.
Append itattach.
**Now align the items in the itab as above .
Loop at Itab.
concatenate itab-vbeln
itab-posnr
itab-matnr into itattach separated by con2.
concatenate con1 itattach into itattach .
Append itattach.
endloop.
endform. " BUILD_XLS_FORMAT
*& Form send_mail_as_xls_attachment
text
-->P_ITMESSAGE text
-->P_ITATTACH text
-->P_P_EMAIL text
-->P_0116 text
-->P_0117 text
-->P_0118 text
-->P_0119 text
form send_mail_as_xls_attachment tables p_itmessage
p_itattach
using p_email
p_mtitle
p_format
p_filename
p_attdescription.
Data : xdocdata like sodocchgi1,
xcnt type i.
*Fill the document data.
xdocdata-doc_size = 1.
*Populate the subject/generic message attributes.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_langu = sy-langu.
xdocdata-obj_descr = p_mtitle.
*Fill the document data and fetch size of attachment.
clear xdocdata.
read table itattach index xcnt.
xdocdata-doc_size = ( xcnt - 1 ) * 255 + strlen( itattach ).
xdocdata-doc_size = ( xcnt - 1 ) * 255.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_langu = sy-langu.
xdocdata-obj_descr = p_mtitle.
clear itattachment. refresh itattachment.
itattachment[] = p_itattach[].
*Describe the body of the message.
clear itpacklist. refresh itpacklist.
itpacklist-transf_bin = 'X'.
itpacklist-head_start = '1'.
itpacklist-head_num = '0'.
itpacklist-body_start = '1'.
describe table itattachment lines itpacklist-body_num .
itpacklist-doc_type = 'TXT'.
itpacklist-doc_type = 'XLS'.
append itpacklist.
*Create attachment notification.
itpacklist-transf_bin = 'X'.
itpacklist-head_start = '1'.
itpacklist-head_num = '1'.
itpacklist-body_start = '1'.
describe table itattachment lines itpacklist-body_num .
itpacklist-doc_type = p_format.
itpacklist-obj_name = p_filename.
itpacklist-obj_descr = p_attdescription.
itpacklist-doc_size = itpacklist-body_num * 255 .
append itpacklist.
*FIll the receivers list.
Clear itreclist. refresh itreclist.
itreclist-receiver = p_email.
itreclist-rec_type = 'U'.
itreclist-com_type = 'INT'.
itreclist-notif_del = 'X'.
itreclist-notif_ndel = 'X'.
*itreclist-notif_read = 'X'.
append itreclist.
*CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = xdocdata
PUT_IN_OUTBOX = 'X'
commit_work = 'X'
SENDER_ADDRESS = SY-UNAME
tables
packing_list = itpacklist
CONTENTS_BIN = itattachment
CONTENTS_TXT = itmessage
receivers = itreclist
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.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = xdocdata
PUT_IN_OUTBOX = 'X'
TABLES
packing_list = itpacklist
CONTENTS_BIN = itattachment
CONTENTS_TXT = itmessage
receivers = itreclist
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.
endform. " send_mail_as_xls_attachment
Just execute the above code and let me know.
What is the sap version u r using .
Vijay -
Sending mail with excel attachment-improper format
Dear experts,
I am sending a mail to outlook with an excel attachment. The mail is sent with attachment and the data, but all in one cell.
I am using SO_NEW_DOCUMENT_ATT_SEND_API1. What parameters do i need to manipulate to have data in different columns of excel? I am using "packing_list" table of FM. But dont know the exact parameters to be passed. Can anyone help with the same please?
Best regards and thanks!
Sumit Nene.Hello Sumit,
I am using same function module to send mail with excel attachment.
Below I am attaching my own code for your reference.
Data which u want to add in excel file is maintain in IT_OBJBIN i.e. document information.
CLEAR :IMESSAGE,IT_OBJBIN,IT_OBJPACK,IT_RECLIST.
REFRESH: IMESSAGE[ ] , IT_OBJBIN[ ] , IT_OBJPACK[ ] , IT_RECLIST[ ].
" populate the text for body of the mail
CLEAR WA_IMESSAGE.
CONCATENATE 'Board : ' P_BOARD ':' 'Please find the excel attached for the list of Material whose routing is created' INTO WA_IMESSAGE-LINE.
APPEND WA_IMESSAGE TO IMESSAGE.
"document information
W_DOC_CHNG-OBJ_NAME = 'Excel'.
IF NOT P_BOARD IS INITIAL.
CONCATENATE 'Board : ' P_BOARD ':' 'List Of Routing Materials' INTO W_DOC_CHNG-OBJ_DESCR.
ELSE.
CONCATENATE 'List Of' ' Routing Materials' INTO W_DOC_CHNG-OBJ_DESCR.
ENDIF.
W_DOC_CHNG-SENSITIVTY = 'F'. " ->Functional object
" displaying material , plant in the excel
CONCATENATE 'BOARD NO : ' P_BOARD INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
CONCATENATE 'MATERIAL' 'PLANT' 'DESCRIPTION' INTO WA_OBJBIN SEPARATED BY C_TAB.
CONCATENATE C_RET WA_OBJBIN INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
CLEAR : WA_OBJBIN.
LOOP AT IT_DOWNLOAD INTO WA_DOWNLOAD. "It_orders is the internal table to be transferred to excel
CONCATENATE WA_DOWNLOAD-MATNR WA_DOWNLOAD-WERKS WA_DOWNLOAD-DESC INTO WA_OBJBIN SEPARATED BY C_TAB.
CONCATENATE C_RET WA_OBJBIN INTO WA_OBJBIN.
APPEND WA_OBJBIN TO IT_OBJBIN.
ENDLOOP.
DESCRIBE TABLE IT_OBJBIN LINES V_LINES_BIN. " no of lines for excel data
" pack the data as RAW
CLEAR WA_IT_OBJPACK-TRANSF_BIN. "Obj. to be transported not in binary form
WA_IT_OBJPACK-HEAD_START = 1. "Start line of object header in transport packet
WA_IT_OBJPACK-HEAD_NUM = 0. "Number of lines of an object header in object packet
WA_IT_OBJPACK-BODY_START = 1. "Start line of object contents in an object packet
WA_IT_OBJPACK-BODY_NUM = MESSAGE_LINES. "Number of lines of the mail body
WA_IT_OBJPACK-DOC_TYPE = 'RAW'.
APPEND WA_IT_OBJPACK TO IT_OBJPACK.
" pack the data as excel
WA_IT_OBJPACK-TRANSF_BIN = 'X'.
WA_IT_OBJPACK-HEAD_START = 1.
WA_IT_OBJPACK-HEAD_NUM = 1.
WA_IT_OBJPACK-BODY_START = 1.
WA_IT_OBJPACK-BODY_NUM = V_LINES_BIN. "no of lines of it_orders to give no of unprocessed orders
WA_IT_OBJPACK-DOC_TYPE = 'XLS'. " -> excel fomat
WA_IT_OBJPACK-OBJ_NAME = 'EXCEL ATTACHMENT'.
" attachment name
IF NOT P_BOARD IS INITIAL.
CONCATENATE P_BOARD '.XLS' INTO WA_IT_OBJPACK-OBJ_DESCR.
ELSE.
CONCATENATE 'LIST' '.XLS' INTO WA_IT_OBJPACK-OBJ_DESCR.
ENDIF.
WA_IT_OBJPACK-DOC_SIZE = V_LINES_BIN * 255.
APPEND WA_IT_OBJPACK TO IT_OBJPACK.
" creating email id
DATA: STR1 TYPE STRING,
STR2 TYPE STRING,
STR3 TYPE STRING,
ITAB TYPE TABLE OF STRING.
DATA : WA_I LIKE LINE OF ITAB.
SPLIT P_EMAIL AT ',' INTO: TABLE ITAB.
e-mail receivers.
CLEAR WA_IT_RECLIST.
LOOP AT ITAB INTO WA_I.
WA_IT_RECLIST-RECEIVER = WA_I.
WA_IT_RECLIST-RECEIVER = V_MAILADDR.
WA_IT_RECLIST-EXPRESS = 'X'.
WA_IT_RECLIST-REC_TYPE = 'U'. "-> Internet address
APPEND WA_IT_RECLIST TO IT_RECLIST.
CLEAR WA_IT_RECLIST.
ENDLOOP.
" sending mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
PACKING_LIST = IT_OBJPACK
OBJECT_HEADER =
CONTENTS_BIN = IT_OBJBIN
CONTENTS_TXT = IMESSAGE
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = IT_RECLIST
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
COMMIT WORK.
IF SY-SUBRC = 0.
MESSAGE I001 WITH 'Routing is Created for Board' P_BOARD 'and Mail send on e-mail id :' P_EMAIL.
ENDIF. -
Hyperion Essbase QAT Menu with Excel 2007
I just upgraded to Hyperion Essbase 11.1.1.3 and I recently upgraded to Excel 2007. Moving to XL2007 made the Essbase add-in two levels deep in the ribbon so I wanted to move this to the Quick Access Toolbar (QAT). I found a great tool to develop QAT menus authored by [url http://www.rondebruin.nl/qat.htm]Ron Debruin.
I took his code and customized it to work with the Hyperion commands. Picture of menu here: http://i.imgur.com/X7zFS.jpg
Everything worked great for a few month for both myself and about 75 coworkers but once we upgraded to Essbase 11.1.1.3 from 7, the menu macros stopped working for almost everyone except for myself and a few others.
I set this macro in the xlstart folders so that it opens with excel. The QAT menu still appears for everyone, but when selecting any of the menu items to run, nothing runs.
Example: When running
Sub MyMacro21()
Call EssMenuVConnect
End Subfrom the custom QAT menu, nothing happens. What should occur is a popup login for Hyperion. I've even tried to run the code outside of the QAT menu and it does not work so this leads me to believe something is wrong with my Hyperion code. Now mind you, this work fine on my machine.
I'm unable to determine the cause for the macro to not work. Any help or troubleshooting pointers would be appreciated.
Here is the code that I'm using.
Thanks in advance for any help.
-Risk
<font color="blue">First Module (Hyperion Code and subs for the QAT menu)</font>
Option Explicit
Option Private Module
Declare Function EssMenuVRetrieve Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVKeepOnly Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVZoomIn Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVZoomOut Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVPivot Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVWizard Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVQueryDesigner Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVFlashBack Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVOptions Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVMemberSelection Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVCurrencyReport Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVCascade Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVRetrieveLock Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVLock Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVUnlock Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVSend Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVCalculation Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVConnect Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVDisconnect Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVDatalessNav Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVLinkedObjects Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVRemoveOnly Lib "ESSEXCLN.XLL" () As Long
Declare Function EssMenuVLaunchTableau Lib "ESSEXCLN.XLL" () As Long
' The following prototype declares the VBA-specific functions
Declare Function EssVGetHctxFromSheet Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Long
Declare Function EssVGetMemberInfo Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal mbrName As Variant, ByVal action As Variant, ByVal aliases As Variant) As Variant
Declare Function EssVFreeMemberInfo Lib "ESSEXCLN.XLL" (ByRef memInfo As Variant) As Long
Declare Function EssVFreeDataPoint Lib "ESSEXCLN.XLL" (ByRef Info As Variant) As Long
' The following constants are suitable as actions
' for the EssVGetMemberInfo function
Const EssChildLevel = 1
Const EssDescendentLevel = 2
Const EssBottomLevel = 3
Const EssSiblingLevel = 4
Const EssSameLevel = 5
Const EssSameGenerationLevel = 6
Const EssCalculationLevel = 7
Const EssParentLevel = 8
Const EssDimensionLevel = 9
' The following prototypes declare the Visual Basic
' Extended Spreadsheet macro-equivalent functions
Declare Function EssVCalculate Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal calcScript As Variant, ByVal synchronous As Variant) As Long
Declare Function EssVCancelCalc Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Long
Declare Function EssVCascade Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal selection As Variant, ByVal path As Variant, ByVal prefix As Variant, ByVal suffix As Variant, ByVal level As Variant, ByVal openFile As Variant, ByVal copyFormats As Variant, ByVal overwrite As Variant, ByVal listFile As Variant) As Long
Declare Function EssVCell Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ParamArray memberList() As Variant) As Variant
Declare Function EssVConnect Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal userName As Variant, ByVal password As Variant, ByVal server As Variant, ByVal application As Variant, ByVal database As Variant) As Long
Declare Function EssVDisconnect Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Long
Declare Function EssVFlashBack Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Long
Declare Function EssVGetCurrency Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Variant
Declare Function EssVGetDataPoint Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal cell As Variant, ByVal range As Variant, ByVal aliases As Variant) As Variant
Declare Function EssVGetGlobalOption Lib "ESSEXCLN.XLL" (ByVal item As Long) As Variant
Declare Function EssVGetSheetOption Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal item As Variant) As Variant
Declare Function EssVKeepOnly Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal selection As Variant) As Long
Declare Function EssVRemoveOnly Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal selection As Variant) As Long
Declare Function EssVPivot Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal startPoint As Variant, ByVal endPoint As Variant) As Long
Declare Function EssVRetrieve Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal lockFlag As Variant) As Long
Declare Function EssVSendData Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant) As Long
Declare Function EssVSetCurrency Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal currencyIdentifier As Variant) As Long
Declare Function EssVSetGlobalOption Lib "ESSEXCLN.XLL" (ByVal item As Long, ByVal globalOption As Variant) As Long
Declare Function EssVSetSheetOption Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal item As Variant, ByVal sheetOption As Variant) As Long
Declare Function EssVUnlock Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant) As Long
Declare Function EssVZoomIn Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal selection As Variant, ByVal level As Variant, ByVal across As Variant) As Long
Declare Function EssVZoomOut Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal range As Variant, ByVal selection As Variant) As Long
Declare Function EssVSetMenu Lib "ESSEXCLN.XLL" (ByVal setMenu As Boolean) As Long
Declare Function EssVGetStyle Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal styleType As Variant, ByVal dimName As Variant, ByVal item As Long) As Variant
Declare Function EssVSetStyle Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal styleType As Variant, ByVal dimName As Variant, ByVal item As Long, ByVal newValue As Variant) As Long
Declare Function EssVLoginSetPassword Lib "ESSEXCLN.XLL" (ByVal sheetName As Variant, ByVal newPassword As Variant, ByVal oldPassword As Variant, ByVal server As Variant, ByVal userName As Variant) As Long
Declare Function EssVSetSKUMouse Lib "ESSEXCLN.XLL" (ByVal fSKUWithMouse As Variant) As Long
Sub MyMacro1()
Call EssMenuVRetrieve
End Sub
Sub MyMacro2()
Call EssMenuVKeepOnly
End Sub
Sub MyMacro3()
Call EssMenuVRemoveOnly
End Sub
Sub MyMacro4()
Call EssMenuVZoomIn
End Sub
Sub MyMacro5()
Call EssMenuVZoomOut
End Sub
Sub MyMacro7()
Call EssMenuVDatalessNav
End Sub
Sub MyMacro9()
Call EssMenuVLinkedObjects
End Sub
Sub MyMacro12()
Call EssMenuVFlashBack
End Sub
Sub MyMacro13()
Call EssMenuVOptions
End Sub
Sub MyMacro14()
Call EssMenuVMemberSelection
End Sub
Sub MyMacro15()
Call EssMenuVCurrencyReport
End Sub
Sub MyMacro17()
Call EssMenuVLock
End Sub
Sub MyMacro18()
Call EssMenuVUnlock
End Sub
Sub MyMacro19()
Call EssMenuVSend
End Sub
Sub MyMacro20()
Call EssMenuVCalculation
End Sub
Sub MyMacro21()
Call EssMenuVConnect
End Sub
Sub MyMacro22()
Call EssMenuVDisconnect
End Sub
Sub MyMacro23()
Call SHRetrieveRetain
End Sub
Sub MyMacro24()
Call WBRetrieveRetain
End Sub
Sub MyMacro25()
Call SHRetrieveSuppress
End Sub
Sub MyMacro26()
Call WBRetrieveSuppress
End Sub<font color="blue">Second Module (this is Ron Debruin's QAT code)</font>
Option Explicit
Option Private Module
'TIP:
'After you click on "Edit Menu" in the menu you can change the button image.
'Right click on the QAT and choose Customize Quick Access Toolbar.
'In the “Choose commands from” dropdown choose Macros and in the
'Customize Quick Access Toolbar dropdown choose "For My Add-in.xlam".
'Select the RDBDisplayPopUp macro and press the Modify button to change the icon.
Sub WBCreatePopUp()
Dim MenuSheet As Worksheet
Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, NextLevel, MacroName, Caption, Divider, FaceId
' Location for menu data
Set MenuSheet = ThisWorkbook.Sheets("MenuSheet")
' Make sure the menus aren't duplicated
Call WBRemovePopUp
' Initialize the row counter
Row = 5
' Add the menu, menu items and submenu items using
' data stored on MenuSheet
' First we create a PopUp menu with the name of the value in B2
With application.CommandBars.Add(ThisWorkbook.Sheets("MenuSheet"). _
range("B2").Value, msoBarPopup, False, True)
Do Until IsEmpty(MenuSheet.Cells(Row, 1))
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
MacroName = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With
Select Case MenuLevel
Case 2 ' A Menu Item
If NextLevel = 3 Then
Set MenuItem = .Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem = .Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = ThisWorkbook.Name & "!" & MacroName
End If
MenuItem.Caption = Caption
If FaceId <> "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True
Case 3 ' A SubMenu Item
Set SubMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = Caption
SubMenuItem.OnAction = ThisWorkbook.Name & "!" & MacroName
If FaceId <> "" Then SubMenuItem.FaceId = FaceId
If Divider Then SubMenuItem.BeginGroup = True
End Select
Row = Row + 1
Loop
End With
End Sub
Sub RDBDisplayPopUp()
On Error Resume Next
application.CommandBars(ThisWorkbook.Sheets("MenuSheet").range("B2").Value).ShowPopup
On Error GoTo 0
End Sub
Sub EditMenu()
ThisWorkbook.IsAddin = False
End Sub
Sub WBRemovePopUp()
On Error Resume Next
application.CommandBars(ThisWorkbook.Sheets("MenuSheet").range("B2").Value).Delete
On Error GoTo 0
End Sub<font color="blue">Third Module (some custom Essbase comands to toggle between "retain formula options" and "suppress zero options")</font>
Option Explicit
Sub WBRetrieveRetain()
Dim sh As Worksheet, HidShts As New Collection 'to handle hidden sheets
For Each sh In ActiveWorkbook.Worksheets
If Not sh.Visible Then
HidShts.Add sh
sh.Visible = xlSheetVisible
End If
Next sh
For Each sh In Worksheets
Sheets(sh.Name).Activate
'Turn On Retain and Turns off Suppress and double clicks
If EssVGetSheetOption(Empty, 6) = True Or _
EssVGetSheetOption(Empty, 7) = True Then
Call EssVSetSheetOption(Empty, 6, False)
Call EssVSetSheetOption(Empty, 7, False)
End If
If EssVGetGlobalOption(1) = True Or _
EssVGetGlobalOption(2) = True Then
Call EssVSetGlobalOption(1, False)
Call EssVSetGlobalOption(2, False)
End If
Call EssVSetSheetOption(Empty, 11, True)
Call EssVSetSheetOption(Empty, 21, True)
Call EssVSetSheetOption(Empty, 22, True)
Next
For Each sh In HidShts
sh.Visible = xlSheetHidden
Next sh
End Sub
Sub SHRetrieveRetain()
'Turn On Retain and Turns off Suppress and double clicks
If EssVGetSheetOption(Empty, 6) = True Or _
EssVGetSheetOption(Empty, 7) = True Then
Call EssVSetSheetOption(Empty, 6, False)
Call EssVSetSheetOption(Empty, 7, False)
End If
If EssVGetGlobalOption(1) = True Or _
EssVGetGlobalOption(2) = True Then
Call EssVSetGlobalOption(1, False)
Call EssVSetGlobalOption(2, False)
End If
Call EssVSetSheetOption(Empty, 11, True)
Call EssVSetSheetOption(Empty, 21, True)
Call EssVSetSheetOption(Empty, 22, True)
End Sub
Sub SHRetrieveSuppress()
'Turn Off Retain and Turns on Suppress
If EssVGetSheetOption(Empty, 11) = True Or _
EssVGetSheetOption(Empty, 21) = True Or _
EssVGetSheetOption(Empty, 22) = True Then
Call EssVSetSheetOption(Empty, 11, False)
Call EssVSetSheetOption(Empty, 21, False)
Call EssVSetSheetOption(Empty, 22, False)
End If
Call EssVSetSheetOption(Empty, 6, True)
Call EssVSetSheetOption(Empty, 7, True)
End Sub
Sub WBRetrieveSuppress()
Dim sh As Worksheet, HidShts As New Collection 'to handle hidden sheets
For Each sh In ActiveWorkbook.Worksheets
If Not sh.Visible Then
HidShts.Add sh
sh.Visible = xlSheetVisible
End If
Next sh
For Each sh In Worksheets
Sheets(sh.Name).Activate
'Turn Off Retain and Turns on Suppress
If EssVGetSheetOption(Empty, 11) = True Or _
EssVGetSheetOption(Empty, 21) = True Or _
EssVGetSheetOption(Empty, 22) = True Then
Call EssVSetSheetOption(Empty, 11, False)
Call EssVSetSheetOption(Empty, 21, False)
Call EssVSetSheetOption(Empty, 22, False)
End If
Call EssVSetSheetOption(Empty, 6, True)
Call EssVSetSheetOption(Empty, 7, True)
Next
For Each sh In HidShts
sh.Visible = xlSheetHidden
Next sh
End Sub<font color="blue">Excel Object Code</font>
Option Explicit
Private Sub CommandButton1_Click()
Call WBCreatePopUp
MsgBox "Click on the button in the QAT to see if your menu is correct.", vbOKOnly, "Favorite Macro Menu"
End Sub
Private Sub CommandButton2_Click()
Call WBCreatePopUp
range("A1").Select
ThisWorkbook.IsAddin = True
ThisWorkbook.Save
End Sub
Private Sub CommandButton3_Click()
ThisWorkbook.IsAddin = True
ThisWorkbook.Saved = True
End Sub
Option Explicit
Private Sub Workbook_Open()
Call WBCreatePopUp
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call WBRemovePopUp
End SubHi Mathieu,
As per support matrix documentation, Essbase 7.1.3 is not supported with Excel 2007.
You may have to upgrade to client version 7.1.6.7 which supports Excel 2007.
Thanks,
Raja
Maybe you are looking for
-
Page Specific Persistence using Session Variables
Hi, I have read a lot about using session variables to persist the ReportDocument object across page loads. This works fine if you have just one page open with one report. The problem I am having is I have a web application that makes 30 or 40 diff
-
IPhoto Slideshows: major loss of quality when passed to iMovie or iDVD
Problem: Slideshows created in iPhoto and exported to a Quicktime movie lose quality when exported from iMovie or iDVD. I've read through many threads in both the iMovie and iDVD forums, and I've done a lot of testing to find the source of my frustra
-
Password for verify distribution of ibooks document
There are a possibilitie to protect the main document with a password but as soon as you export that document so the customer can verify (download to an iPad) then the password is gone. Security risk since I only whants to share the almost done docum
-
Problem in Proxy call from an application deployed in J2EE engine
Hi, I am trying Java Sender Proxy --> XI --> DB. I have generated o/b proxies using integration builder. <b>Following is the code that i am using for proxy call and it runs absolutely fine when runnning stand alone</b> <code Controller.java> Properti
-
SD card reader not working in Satellite A305 series
I have an A305 series laptop. It's only 6 weeks old and I bought it brand new. The sd card reader has worked fine up until today. It's not working anymore. Device manager shows it's disabled. I tried to enable it but it says Windows can't enable it.