Problèmes connus et conseils sur Excel Services
The following are a known issues and tips for working with Excel Services.
Excel Web Service
Viewing the WSDL Location
Vous pouvez afficher la page WSDL (Web Services Description Language) d’Excel Web Services en accédant à l’URL suivante sur le serveur : http://<server>/<customsite>/_vti_bin/excelservice.asmx?WSDL
Si vous n’avez pas de site personnalisé, vous pouvez afficher le WSDL à l’aide de l’URL suivante : http://<server>/_vti_bin/excelservice.asmx?WSDL
Pour plus d’informations, consultez Accès à l’API SOAP.
Understanding Excel Web Services and Namespaces
The following are Excel web services and namespaces:
- The single web service object that contains all the API methods: ExcelService
- Espace de noms de schéma :
http://schemas.microsoft.com/office/excel/server/webservices
- Nom de la page du service web : ExcelService.asmx
Linking Locally or to a Web Service
In certain scenarios, you should link directly to Microsoft.Office.Excel.Server.WebServices.dll and access it as you would any local assembly, instead of calling it as a web service through SOAP over HTTP.
Pour plus d’informations et pour obtenir des instructions sur l’utilisation de la liaison directe, consultez appels SOAP Loop et liaison directe.
Understanding Invalid Characters
The calls to the GetCell and GetRange methods will fail if the workbook cells contain characters that are invalid in an XML response.
For example, if a cell contains characters with hexadecimal values 0x1, 0x2 ... 0x8, the ASP.NET parser will throw an exception that the value of the character being written to the XML response is invalid:
System.InvalidOperationException : le client a trouvé le type de contenu de réponse 'text/html ; charset=utf-8', mais attendu 'text/xml'. La demande a échoué avec le message d’erreur : -- <titre> de l’en-tête><html><' ', valeur hexadécimale 0x01, est un caractère non valide.
Ce comportement est normal. La spécification XML qui définit les caractères autorisés dans une réponse XML valide spécifie que les valeurs hexadécimales values 0x1, 0x2 ... 0x8 ne sont pas des caractères XML valides :
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] / any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. /
Pour plus d’informations, consultez Spécification XML (Extensible Markup Language) W3C.
Saving a Workbook
When you make changes to a workbookfor example, by setting values to a range using Excel Web Servicesthe changes to the workbook are preserved only for that particular session. The changes are not saved or persisted back to the original workbook. When the current workbook session ends (for example, when you call the CloseWorkbook method, or the session times out), changes you made will be lost.
If you want to save changes to a workbook, you can use the GetWorkbook method and then save the workbook using the API of the destination file store. For more information, see How to: Get an Entire Workbook or a Snapshot and Procédure : enregistrer un classeur.
Understanding the Url Property of an Excel Web Services Proxy Class
Do not use the Url property of an Excel Web Services proxy for the location of the workbook you want to open. The Url property of a web service proxy class generated by Visual Studio gets or sets the base URL of the XML web service the client is requesting. Dans le cas d’Excel Web Services, il s’agit généralement des suivants : http://<server name>/_vti_bin/ExcelService.asmx
To specify the location of a workbook, use the OpenWorkbook method instead of the Url property as shown in the following code example.
//Instantiate the web service and make a status array object.
ExcelService xlservice = new ExcelService();
string sheetName = "Sheet1";
//Set the path to the workbook to open.
//TODO: Change the path to the workbook
//to point to a workbook you have access to.
//The workbook must be in a trusted location.
string targetWorkbookPath = "http://myserver02/example/Shared%20Documents/Book1.xlsx";
//Set credentials for requests.
xlservice.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Call the open workbook, and point to the trusted
//location of the workbook to open.
string sessionId = xlservice.OpenWorkbook(targetWorkbookPath, "en-US", "en-US", out outStatus);
Pour plus d’informations, consultez WebClientProtocol.Url, propriété.
Understanding Security
Using Workbook Permissions
Beware of the following issues regarding workbook permissions:
- Excel Web Services utilise le schéma d’autorisation Microsoft SharePoint Foundation pour vérifier que l’appelant a le droit d’appeler des API (autrement dit, effectuer des appels de service web) sur le site SharePoint Foundation (autrement dit, le site web où se trouve Excel Web Services) à distance. If the caller does not have the "Use Remote API" right, the Excel Web Services returns an "HTTP 401 (Unauthorized)" error, and logs an "API authorization failed" event. Excel Web Services performs these authorization checks only for calls that originate as SOAP calls. Calls from applications that link locally to Microsoft.Office.Excel.Server.WebServices.dll are not considered remote calls. Therefore, they are not subject to authorization checks. However, if the application that links locally to Microsoft.Office.Excel.Server.WebServices.dll is itself a SOAP service, and handles the service's SOAP calls, the call to Excel Web Services will seem like a SOAP call (even though the application links directly to Microsoft.Office.Excel.Server.WebServices.dll). In this scenario, Excel Web Services will perform the authorization checks.
- To get the entire workbook (for example, by calling the GetWorkbook method using the
WorkbookType.FullWorkbook
argument), the caller needs "open" permission for the workbook or "read" permission in a file share. - To call the GetApiVersion method, no permission is necessary.
- For the rest of the Excel Web Services methods, besides credentials, the caller needs "view" permission (in SharePoint Foundation) or "read" permission (in a file share) for the workbook.
Trusted Location
The workbooks you want to open in Excel Services must be placed in a trusted location. If not, the Excel Web Services calls to open the workbook will fail.
Pour plus d’informations sur la façon d’approuver un emplacement, consultez How to : Trust a Location et How to : Trust Workbook Locations Using Script.
Visual Studio
Microsoft Visual Studio Proxy Behavior
When Microsoft Visual Studio creates a proxy class for a client project that calls Excel Web Services, it has the following behavior:
If a method has no return value, and one or more out arguments, the first out argument is moved to become the return value. That is, the method in the proxy class will have one less out argument in the method signature. But the signature will have a return value with the type and content of what used to be the first out argument.
The affected Excel Web Services methods are:
- Calculate
- CalculateA1
- CalculateWorkbook
- CancelRequest
- CloseWorkbook
- GetSessionInformation
- Refresh
- SetCell
- SetCellA1
- SetRange
- SetRangeA1
Fonctions Excel Services définies par l’utilisateur
Global Assembly Cache is Checked First, Then the Local Folder
By design in the Microsoft .NET Framework, an assembly in a global assembly cache will be loaded instead of the same assembly in a local folder. The common language runtime will look for an assembly in the global assembly cache first before searching in the local folders.
Therefore, if an assembly is installed in the global assembly cache and is in the UDF list but disabled (or removed from the UDF list altogether), and an identical assembly is installed in a local folder and enabled, the assembly in the global assembly cache will still get loaded and used instead of the same assembly in the local folder.
This does not affect upgrade scenarios in which the assembly version has been modified, which means the assembly is not the same anymore.
Général
Order of Strings in Sharedstring.xml is Not Maintained
Excel Services ne conserve pas l’ordre d’origine des chaînes dans une table de chaînes partagées de classeur (partie Sharedstrings.xml dans le fichier de format XML Microsoft Office Excel). For example, execute the following steps:
- Open a file using Excel.
- Save the file in .xlsx file format.
- Upload the file to a document library that is a trusted location.
- Open the file in the document library by using Excel Web Access.
- Click Open in Excel.
- Save the file in .xlsx file format.
Si vous comparez le fichier Sharedstrings.xml créé à l’étape 2 avec celui créé à l’étape 6, vous constaterez que l’ordre des partiesSharedstrings.xml peut être différent.
You should not write an application that assumes the order of strings in the shared-string table is fixed. For example, you cannot replace the shared-string table with an existing localized translation table. You must adjust to the new ordering of strings in the shared-string table.