Microsoft Embedded - Editar un Workbook antes de cargarlo con Excel Web Access

<<>>
 
Vista:
Imágen de perfil de Ilich

Editar un Workbook antes de cargarlo con Excel Web Access

Publicado por Ilich (1 intervención) el 17/06/2016 01:53:44
Buenas tardes.

Llevo varias horas intentando hacer que un archivo de excel que esta almacenado en OneDrive pueda ser editado usando la API para Office escrita en JavaEscript (Office.js) y despues de editarlo lo pueda incrustar en mi página web.

Para ser más precisos quiero que una columna de dicho archivo tenga un filtro antes de que todo el libro de trabajo se muestre en la página de Excel.

Este es el código que uso para incrustar el archivo en la web pero no tengo ni idea de como usar el libro como un objeto manejable antes de mostrarlo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<div id="myExcelDiv" style="width: device-widthpx; height: 900px"></div>
<script type="text/javascript" src="https://r.office.microsoft.com/r/rlidExcelWLJS?v=1&kip=1"></script>
//JS API para Excel
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
<script type="text/javascript">
	/*
	 * This code uses the Microsoft Office Excel Javascript object model to programmatically insert the
	 * Excel Web App into a div with id=myExcelDiv. The full API is documented at
	 * https://msdn.microsoft.com/es-ES/library/hh315812.aspx. There you can find out how to programmatically get
	 * values from your Excel file and how to use the rest of the object model. 
	 */
 
	// Use this file token to reference Workbook  in Excel's APIs
       //Cambie el token del archivo por motivos de seguridad
	var fileToken = "XXXXXXXXXXXXXXXXXXXXX/-1111164657429427934/t=0&s=0&v=!ALL0Fo5yAAUs8vc";
	var ewa = null;
 
	// run the Excel load handler on page load
	if (window.attachEvent) {
		window.attachEvent("onload", loadEwaOnPageLoad);
	} else {
		window.addEventListener("DOMContentLoaded", loadEwaOnPageLoad, false);
	}
 
	function loadEwaOnPageLoad() {
		var props = {
			uiOptions: {
				showDownloadButton: false,
				showGridlines: false,
				showRowColumnHeaders: false,
				showParametersTaskPane: false
			},
			interactivityOptions: {
				allowTypingAndFormulaEntry: false,
				allowParameterModification: false,
				allowSorting: false,
				allowFiltering: false,
				allowPivotTableInteractivity: false
			}
		};
 
		Ewa.EwaControl.loadEwaAsync(fileToken, "myExcelDiv", props, onEwaLoaded);
 
		if (typeof (Ewa) != "undefined")
        	{
            	Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
        	}
        else
        	{
            	alert("Error - the EWA JS is not loaded.");
        	}
	}
 
	function ewaApplicationReady()
    	{
    		// Get a reference to the EWA.
        	ewa = Ewa.EwaControl.getInstances().getItem(0);
 
    	}
 
	function onEwaLoaded(result) {
		// Display the Workbook path.
    		alert(ewa.getActiveWorkbook().getActiveSheet().getName());
		/*
		 * Add code here to interact with the embedded Excel web app.
		 * Find out more at https://msdn.microsoft.com/es-ES/library/hh315812.aspx.
		 */
	}
 
</script>

Según yo tendría que usar el Token que genera Excel online para abrir el archivo como un objeto antes de mostrarlo con Excel Web Acces (EWA).

Sinceramente no sé si este haciendo algo mal...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder