コード例 #1
0
            /// <summary>
            /// Convert workbook to some format.	
            /// </summary>
            /// <param name="format">WorkbookExportFormat</param>
            /// <param name="password">The workbook password.</param>
            /// <param name="outPath">Path to save result. Must be a Cloud storage path e.g. MyFolder\out.pdf</param>
            public void ConvertWorkbookToSomeFormat(WorkbookExportFormat format, string password, string outPath, string inputFilePath)
            {
                // PUT 	cells/convert?appSid={appSid}&format={format}&password={password}&outPath={outPath} 

                string apiUrl = string.Format(@"cells/convert?format={0}&password={1}&outPath={2}",
                                                format, password, outPath);

                ServiceController.Put(apiUrl, AppSid, AppKey);
            }
コード例 #2
0
            /// <summary>
            /// Export workbook .	
            /// </summary>
            /// <param name="name">Document name.</param>
            /// <param name="format">The conversion format.</param>
            /// <param name="password">The document password.</param>
            /// <param name="isAutoFit">Set document rows to be autofit.</param>
            /// <param name="folder">Document folder.</param>
            /// <param name="outPath">Path to save result. It can be local (e.g. c:\out.pdf) or cloud storage path (MyFolder\out.pdf). The conversion result for TeX and HTML formats can contain multiple files so it is returned as zip archive.</param>
            /// <param name="storage">The document storage.</param>
            public void ExportWorkbook(string name, WorkbookExportFormat format, string password, bool isAutoFit, string folder, string outPath, string storage = "")
            {
                // GET 	cells/{name}?appSid={appSid}&format={format}&password={password}&isAutoFit={isAutoFit}&storage={storage}&folder={folder}&outPath={outPath} 

                string apiUrl = string.Format(@"cells/{0}?format={1}&password={2}&isAutoFit={3}&storage={4}&folder={5}&outPath={6}",
                                                name, format, password, isAutoFit, storage, folder, (outPath.Contains(@":\") ? string.Empty : outPath));

                if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath)))
                {
                    using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                    using (Stream file = File.OpenWrite(outPath))
                    {
                        ServiceController.CopyStream(responseStream, file);
                    }
                }
                else
                {
                    ServiceController.Get(apiUrl, AppSid, AppKey);
                }
            }