Javascripting in Excel OWC in WIB
Hi all,
Anyone out there know how to return a range value of an item in an embedded excel layout?
Javascript in HTML layouts uses methods (e.g. getElementById, search etc) to find items in the HTML layouts, but how would one do the equivalent to find say an account number and return the range values of where it sits in the excel layout?
Any wise ideas fellow earthlings...?
Thanks,
Rael
Hi,
Here's a java script in which i am populating the value of a field (row, column) and also changing the width and height of display.
<script language="jscript">
onload=function () {
var layout_id = "LAYOUT_LAY001";
var maxrow = 11
layout_sheet = getBpsExcel( layout_id );
if (layout_sheet && layout_sheet.ActiveSheet)
{ // Excel OWC available
// set the properties of the component
layout_sheet.style.height = 1000;
layout_sheet.style.width = 1000;
layout_sheet.Cells(1,1).value = "Anand Jain";
//get the maximum row for which the data has been entered
for (i=11; i<100; i++) {
if (layout_sheet.Cells(i,1).value !=null)
{ maxrow++;}
else {break;}
if (layout_sheet.Cells(i,1).value !="")
{ maxrow++;}
else {break;}
alert (maxrow);
alert (layout_sheet.Cells(i,1).value) }
layout_sheet.Columns.AutoFit();
layout_sheet.Cells(maxrow,1).value = "This is the last line";}
function getBpsExcel( layout_id )
var layout_sheet = document.all( layout_id );
var classIds = ["CLSID:0002E559-0000-0000-C000-000000000046", // 2003
"CLSID:0002E551-0000-0000-C000-000000000046", // XP(2002)
"CLSID:0002E510-0000-0000-C000-000000000046"]; // 2000
// if Excel OWC NOT available => try OCX from another known office version
var defClassId = layout_sheet.classid;
for (i = 0; !layout_sheet.ActiveSheet && i < classIds.length; i++) {
if (classIds<i> == defClassId) continue; // skip default
// remove the irrelevant object
layout_sheet.removeNode();
// create new object & set size attributes
layout_sheet = document.createElement("OBJECT");
layout_sheet.style.height = "0";
layout_sheet.style.width = "0";
// append to dom and activate OCX
var layout_div = document.all( layout_id + "-div" );
layout_sheet = layout_div.appendChild(layout_sheet);
layout_sheet.classid = classIds<i>;
layout_sheet.id = layout_id;
} // loop over OCX classes
if (layout_sheet.ActiveSheet) { // Excel OWC available
// send the office version to the backend
document.all(layout_id + "-class").value = layout_sheet.classid;
layout_sheet.ActiveSheet.Protection.Enabled = false;
// For input handling of excel we need to submit
// the decimal separator from regional settings on the client
// Take sample values from the OWC
var cellValue;
var cell = layout_sheet.cells(1,1);
var oldFormat = cell.NumberFormat;
cell.NumberFormat = "#,##0.0";
bpsClipboardStore();
cell.ParseText("1.5", "t");
cellValue = getBpsCell(cell);
if (cellValue == "") { // clipboard failed, get system setting
cellValue = new Number(1.5 ).toLocaleString();
document.all("bps-float_number").value = cellValue;
cell.ParseText("1000", "t");
cellValue = getBpsCell(cell);
if (cellValue == "") { // clipboard failed, get system setting
cellValue = new Number(1000).toLocaleString();
document.all("bps-thousand_number").value = cellValue;
bpsClipboardRestore();
cell.NumberFormat = oldFormat;
cell.clear();
return layout_sheet;
</script>
Similar Messages
-
Texts on bps web (excel OWC)
Hello gurus.
I have a bps web based (excel owc).
SAP Gui is defined on english, but web is defined as portuguese. How can I redefine as english?
I have the problem with texts, i define them in english but it doesn´t appear on web...
Thks.
Vitor
P.S. Points will be regarded.Hi Vitor,
I am not sure, I don´t know URL possibilities that much.
If there is already any parameter in the url showing a language, then just try to change it.
If not, you can probably just put one at the end of the URL should be something like language=EN.
regards
Cornelia -
BW-BPS Excel OWC hierarchy display
I have created a layout that uses hierarchy with the excel display. in transaction BPS0, the layout displayed in excel shows the hierarchy using the outline feature of excel as expected.
However, when this layout is deployed on the web using the excel OWC, the hiererchy levels show up but the outline feature of the excel is not available - so I am unable to collapse hierarchy levels. Is this standard behavior? Is there a way to do this?
Note: It works ok with the ALV display but we want to use excel OWC.
Message was edited by:
Alvin Josephhi...for hierarchies, use a web item called 'Hierarchy list' and give the respective infoobject in it.
-
Microsoft Fix interferes with BPS Excel OWC
Dear Experts,
we had just rolled ou a MS security fix
http://www.microsoft.com/technet/security/advisory/973472.mspx
which deactivates some parts og ERxcel OWC.
As a consequence, BPS Excel layouts don't work anymore.
Has anybody already found some information on this? (a SAP note?)
Or is there already a workaround or something like that?
Best regards
GregorHi Madhu,
very interesting. Which one of the workarounds did you use?
There are 4 described in the MS Note at http://www.microsoft.com/technet/security/advisory/973472.mspx
1) Prevent Office Web Components Library from running in Internet Explorer
2) Unregister the Office Web Components Library
3) Restrict Web sites to only your trusted Web sites
4) Set Internet and Local intranet security zone settings to "High" to prompt before running ActiveX controls in these zones
The information I have on this meanwhile via a SAP Customer Note is, that
- YES excel BPS layouts dont work with the MS Workaround Fix
- SAP is waiting for MS to fix the underlying vulnerability which would make the workaround obsolete
Best regards
Gregor -
Is it possible to change the formatting of Excel in place
Hi,
is it possible to change the standard formatting of columns and texts when using Excel inplace (Excel on the web for the BPS )?
Many thanks,
Simon CohenSimon,
I am afraid you can't modify styles using excel in place.
Note 632333 says the following :
List of the features the Excel OWC can use from the template:
Text format - font, size, colour
Cell format - background colour, border, alignment
Number format
"Simple" formulas
Panes Split and Freeze (only for Office versions 2002(XP) or higher)
Nevertheless this applies only for cells which are not filled by BPS runtime. All texts and values written by BPS runtime into the template use standard styles. The styles cannot be changed, see below.
List of features that are not available in the Excel OWC:
Styles. Consequently no changes to the SAP standard styles are taken over to the OWC. Therefore the features mentioned above are available only for the cells not containing a transaction specific data
VB Macros. When needed, the designer can use a script language (VBScript, JavaScript) to access the DOM of the OWC. You can include HTML into a text component in the Web Interface customizing (tn BPS_WB) and place your script code there.
Cell and text formats not mentioned above (e.g. text orientation,...)
Line brakes within a cell
Panes Split and Freeze (only for Office version 2000)
Embeded elements (like form objects, pictures, background picture,...)
Having more than one worksheet in the Excel OWC
In comparison to HTML based planning layouts the Excel layouts do not identify the position of the documents.
Hope it helps,
Alberto -
Hi,
I have a BPS layout with a largest value in a cell of one column. The amount is represented by ######### because the column is not open to show the value.
The formatting options "Controlling column width" is selected, if I deselect this option is worst.
The user cant fit the column width; the column is not protected.
The largest amount is generated by an excel formula.
What can I do?
Thanks
VictoriaOr <u>after</u> the Layout component in the web interface builder assign a text/html-component with html=true and following script, where you can hardcode the column width
<script language="JavaScript" type="text/javascript">
<!--
var layout_id = "<b>LayoutXXX</b>";
layout_sheet = getBpsExcel( layout_id );
if (layout_sheet && layout_sheet.ActiveSheet) {
// OPEN Excel OWC FOR CHANGE
layout_sheet.ActiveSheet.Protection.Enabled = false;
// SET RANGE (ROW,COL) TO (ROW,COL)
// CHANGE PARAMETERS
range = layout_sheet.Range(layout_sheet.Cells(1 ,1 ),
layout_sheet.Cells(100 ,100 ));
<b>range.Columns.ColumnWidth = 10</b>;
//PROTECT THE SHEET AGAIN
layout_sheet.ActiveSheet.Protection.Enabled = true;
-->
</script> -
Usage of OWC-Webinterface with firefox deletes BPS-data
Dear Experts,
We know that excel OWC in bps-webinterfaces do not work with firefox.
But as we cannot control the local settings at a user workstation it
sometimes happens that a user opens a webinterface with firefox
instead of MS IE.
In this case with firefox he/she does not see any excel sheet. This
behavior is as expected.
But - if he/she then pushes the save-button this will delete the data in BPS-backend
(transactional cube).
We know that firefox is not supported with BW-BPS. But as the use can
not be disabled from server-side this is a big problem.
Has anybody an idea for a good workaround?
I can think of some java script-coding only but this is what we want to avoid.
Best redards
GregorDear all,
for your information.
This problem has been solved for us meanwhile with the help of the supporter of a customer message.
It seems that only webinterfaces of "old style" (before 3.5) showed this behavior. After we had switched them to "new style" the error did not occur anymore.
Gregor -
How can I get selected EXCEL area using java script office API (v 1.0)
Hello everyone,
I need to get values of specified area in an excel sheet using java Script Office API. For an example,
A1:A7 row load into array using JS.And you posted to a C++ forum, not a JavaScript or Excel forum.... why?
Visual C++ MVP -
Simple Calculations in BPS Web
Hi,
I am using the BPS web layouts (ALV Grid not the Excel Web Component). I would like to add a couple of very simple calculations (difference of columns/percentages etc). Is it possible to do this without using the Excel OWC ?
Thanks
ShaileshHi
the simplier way to achieve yor result is to use FOx formula to calculate your results at runtime .
You should create a formula function and add FOX code to it .
Check this link for examples
http://help.sap.com/saphelp_nw04/helpdata/en/d3/8057f830a911d4b2be0050dadfb23f/frameset.htm
Hope it helps
Andr -
Mobile applications with Webdynpro - performance contra functions
Hi all,
By starting this thread I am hoping to get some input from those of you that already developed mobile applications using WebDynpro. In my organisation we currently have several mobile transactions running through ITSmobile (which is normal ABAP programs designed with a small screen in mind), but to make development easier and more future-proof we are looking into using WebDynpro instead.
We use Windows CE devices with Internet Explorer 6. This means standard Webdynpro runs fine, and looks fine. The problem here is that the rendering take very long time, up to 5 seconds. My guess is this is caused by the heavy payload of the stylesheets and JavaScript.
So I have also tried by using the PieClient option, which seems to entirely get rid of both CSS and JavaScript, giving excellent performance. Problem here is that some key functionalities are lost, for example the OnEnter action in a input field and the ability to set focus to a field when a view loads. With these, it seems impossible to create a well-working mobile application that could be operated without using a stylus or keyboard.
I would have liked a third option, with some kind of "lean" CSS and JavaScript, but I don't think that possibility exists.
So how did you solve this problem, what approach did you choose? Looking forward to your input.
/LeifHi Leif
yes you're right Mobile Always Connected, formely known as Web Dynpro reduces the overall dataload to provide an excellent performance espacially optimized for mobile devices.
SAP NetWeaver Mobile Always Connected is supporting Stylesheets with NetWeaver 7.1 EHP 1.
It does get rid of JavaScript in general, but reduces it to a minimum.
It also adds some mobile specific key capabilities like:
- Device Recognition & Device Specific Rendering
- Integration of Peripherals
- Integration of Function Keys
Depending on the NetWeaver Version you are using, you should try to add the following parameter to your URL:
sap-wd-client=PieClient
sap-wd-client=Pie03Client
Example
http://idesmobileonline.sap.com/webdynpro/dispatcher/local/Congress/MobileWorkplace?sap-wd-client=PieClient
Feel free to visit also the mobile capability at SDN. This area provides you forum support for always connected (Mobile Web Dynpro) and for occasionally connected environments. It also includes a forum with a experienced mobile community.
[https://www.sdn.sap.com/irj/sdn/nw-mobile|https://www.sdn.sap.com/irj/sdn/nw-mobile]
Enjoy,
Stefan -
Export to excel with javascript/vbscript or with plsql(html table)
i have searched for a way to export data from OracleXe to excel without losing formatting .
So far i have found 2 possible relatively easy ways that i am still researching
(i do not include the ask tom sylk format way of exporting )
1 to export the query to a html table, while using stylesheets for formatting
(using microsoft specific styles)
2. use of javascript/vbscript to fill an array and write this array to excel with use
of visual basic for applications in excel.This also provides charting capabilities.
I am still researching this two ways, and have
encountered a few obstacles (help would be appreciated)
1 the first way:
a. create a button " export to excel"
b. create the following pl/sql procedure:
owa_util.mime_header('application/vnd.ms-excel');
owa_util.http_header_close;
HTP.PRINT('<html>');
HTP.PRINT('<head>');
HTP.PRINT('<meta http-equiv="Content-Type" content="text/html">');
HTP.PRINT('<title>Title of the HTML File</title>');
HTP.PRINT('</head>');
HTP.PRINT('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
HTP.PRINT('<h1>Heading in the HTML File</h1>');
HTP.PRINT('<p>Some text in the HTML file.');
HTP.PRINT('</body>');
HTP.PRINT('</html>');
htmldb_application.g_page_text_generated := true;
htmldb_application.g_unrecoverable_error := true;
c: run the procedure conditionally based on the button "export to excel"
the problem with this way is that using htmldb_application.g_unrecoverable_error := true; is not the ideal way, because it
stops further processing, but if i leave it out, the export doesn't happen.
To export to excel while retaining data formatting you have to use microsoft excel
specific styles(Seedocumentation on the microsoft site)
2.The second way:
a create a pl/sql procedure or sql query.
b use this query to fill a vbscript/javascript array with values
c write these values to excel with use of vba in excel :
the obstacle i encountered here was that i dont know how to export the result of a
query to a visual basic script or javascript array.Using approach 1) works fine for me.
the problem with this way is that using htmldb_application.g_unrecoverable_error := true;
is not the ideal way, because it
stops further processing, but if i leave it out, the export doesn't happen. Why is this a problem?
I created the button to export the excel file on page 1 and created your pl/sql procedure on page 2 using an onload process.
Works fine.
Other approaches for exporting to excel are:
http://www.oracle.com/technology/pub/articles/saternos_broadcast.html
http://htmldb.oracle.com/pls/otn/f?p=18326:54:5685133631021176591::::P54_ID:1962
~Dietmar. -
Extracting data from Excel To Illustrator javascript or vbscript
Hi all-
I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that. What I would like to do is pretty much the opposite:
1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.
2. Run script(VBSCRIPT,Javascript, doesn't matter)
3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.
4, Save each to a PDF file and name file with text from Excel Column1(Filename)
In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI. I hoped I explained this well enough without causing too much confusion. Thanks in advance.
Filename
Replacement Text
test1.pdf
DWG01
test2.pdf
DWG02
test3.pdf
DWG03
test4.pdf
DWG04As text… \n is new line character and \r is return character. I can't remember which excel uses but they both equate to a line/paragraph… I very quickly threw together an example for you…
#target Illustrator
textToPDF();
function textToPDF() {
if ( app.documents.length == 0 ) { return; }
var doc, csvFile, i, fileArray, opts;
csvFile = File( '~/Desktop/ScriptTest/Test.csv' );
if ( !csvFile.exists ) { return; }
fileArray = readInCSV( csvFile );
doc = app.activeDocument;
opts = new PDFSaveOptions();
opts.pDFPreset = '[Press Quality]';
// Here we loop the main array
for ( i = 0; i < fileArray.length; i++ ) {
// Here we get the second item of sub array i
doc.textFrames.getByName( 'DWG' ).contents = fileArray[i].[1];
// Here we get the first item of sub array i
doc.saveAs( File( fileArray[i].[0] ), opts );
function readInCSV( fileObj ) {
var fileArray, thisLine, csvArray;
fileArray =[];
fileObj.open( 'r' );
while( !fileObj.eof ) {
thisLine = fileObj.readln();
csvArray = thisLine.split( ',' );
fileArray.push( csvArray );
fileObj.close();
return fileArray;
I haven't tested it but it should be close…? -
How to convert html table with all its css properties into excel , by javascript or jQuery
hi,
<script type="text/javascript">
//working java script
function CreateExcelSheet()
var x = Table1.rows
var xls = new ActiveXObject("Excel.Application")
xls.Workbooks.Add
for (i = 0; i < x.length; i++) {
var y = x[i].cells
for (j = 0; j < y.length; j++) {
xls.Cells(i + 1, j + 1).Value = y[j].innerText
} xls.visible = true
function write_to_excel()
str = "";
debugger;
var mytable = document.getElementsByTagName("table")[0];
var rowCount = mytable.rows.length;
var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("td").length;
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
debugger;
ExcelSheet.Application.Visible = true;
for (var i = 0; i < rowCount; i++)
for (var j = 0; j < colCount; j++)
str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
//new funtion
function ExportToExcel(mytblId) {
debugger;
var htmltable = document.getElementById('Table1');
var html = htmltable.innerHTML;
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
//new funtion 2
function write_to_excel2() {
str = "";
debugger;
var mytable = document.getElementById("Table1");
var rowCount = mytable.rows.length;
var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("th").length;
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
//ExcelSheet.Application.Visible = true;
for (var i = 0; i < rowCount; i++)
for (var j = 0; j < colCount; j++)
debugger;
// if (i == 0) {
// str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("th")[j].innerText;
str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
ExcelSheet.autofit;
ExcelSheet.Application.Visible = true;
DisplayAlerts = true;
CollectGarbage();
//csss
function excelExportHtml(Table1, css1)
debugger;
if (css1) {
var styles = [];
//grab all styles defined on the page
$("style").each(function(index, domEle) {
styles.push($(domEle).html());
//grab all styles referenced by stylesheet links on the page
var ajaxCalls = [];
$("[rel=stylesheet]").each(function() {
ajaxCalls.push($.get(this.href, '', function(data) {
styles.push(data);
return $.when.apply(null, ajaxCalls)
.then(function() {
return "<html><style type='text/css'>" + styles.join("\n") + "</style>\n" + table.outerHTML + "</html>";
else {
return $.when({ owcHtml: Table1.outerHTML })
.then(function(result) {
return "<html>" + result.owcHtml + "</html>";
//new
function ExportToExcel() {
$(document).ready(function() {
$("#btnExport").click(function(e) {
window.open('data:application/vnd.ms-excel,' + $('#Table1').html());
alert("jhhklhhklhklh");
//new
$(document).ready(function() {
debugger;
$("[id$=myButtonControlID]").click(function(e) {
window.open('data:application/vnd.ms-excel,' + $('div[id$=divTableDataHolder]').html());
e.preventDefault();
alert("k");
function excel()
{debugger;
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
window.location.href = uri + base64(format(template, ctx))
</script>
i have tried all the above java script and jquery to convert an html table to excel, data are exporting correctly but i want that css of the table should also implent to excel thats not happening,even the property defined inside td and tr aare not implementing
in excelHi avinashk89,
Welcome to post in MSDN forums.
This is not the right forum for your question. Please post in
ASP.NET forums where you could get better support.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
I'm unable to launch an excel file in the Client App from OWA using google chrome. I am able to open the excel file in the web application, but when clicking "Edit Workbook" and selecting "Edit Excel" the file never opens.
Opening developer mode shows a javascript error. This error comes back as:
[blocked] The page at 'https://owa.mysite.com/x/_layouts/xlviewerinternal.aspx?ui=en%2DUS&r…g%2Fsites%2Fmiketest%2Ftestlib%2FForms%2FAllItems%2Easpx&wdEnableRoaming=1' was loaded over HTTPS, but ran insecure content from 'ms-excel:ofv|u|https://intranet.mysite.org/sites/miketest/testlib/SitePageVerification.xlsx':
this content should also be loaded over HTTPS.
Both sites are using https, so I'm unsure what the error is about. Any ideas?Hi Michael,
According to your description, my understanding is that you got an error when you tried to edit excel in client application with Chrome.
Per my knowledge, when you open or edit documents(from SharePoint library) in client application, it requires Open Documents ActiveX controls. Open Documents ActiveX controls limitations on browsers which do not support ActiveX. Currently only 32-bit versions
of Internet Explorer support this functionality. So , for resolving your issue, I suggest you use IE 32-bit.
More indormation, please refer to the link below:
http://technet.microsoft.com/en-us/library/cc263526.aspx
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
I am creating a web page that features an embedded chart made by MS Excel. I would like the chart to automatically update(refresh) to show viewers live information without having to refresh the entire page. I have found that there is a way to enable this through Excel but with my current subscription cannot access that feature. I am hoping that there is a way to achieve this using Adobe Muse CC. If it is not possible, I would like to know if there is a way to add a "refresh" button that refreshes only the embedded section(Excel Chart) of the page for viewers to use manually. Thank you for your help.
Update! The embedded spreadsheet is actually embedded using HTML rather than javascript.
Maybe you are looking for
-
HT1918 Please can you advise how I remove a credit card from my account
I am trying to remove my bank details from my account but can't find where to remove them
-
At night, as soon as I plug my iphone to be recharged, my iphone starts behaving anomaly. It is like somebody has taken control of it. I see the screens moving, music starts playing and then stopping, etc. I have noticed that several nights. What
-
Line chart with one entry in xml doesn't show up
please refer http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001233.html If I use only one entry in expenses array even then the line chart is not shown. below is what I'm using: [Bindable] p
-
Probably I am just stupid, but is there a way to delete a row from a table in Pages for the iPad?
-
I need to pay another 10GB or just pay for the extra one?