1+ /*
2+ * MIT License
3+
4+ * Copyright (c) 2020 Aspose Pty Ltd
5+
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+ import { expect } from "chai" ;
26+ import "mocha" ;
27+
28+ import * as model from "../src/model/model" ;
29+ import * as BaseTest from "./baseTest" ;
30+ var fs = require ( 'fs' ) ;
31+ var path = require ( 'path' ) ;
32+ var assert = require ( 'assert' ) ;
33+ const localPath = "../TestData/" ;
34+ describe ( 'cellsWorkbookPutWorkbookCreate' , function ( ) {
35+ it ( 'should call cellsWorkbookPutWorkbookCreate successfully' , function ( ) {
36+ const dataFile = "ReportData.xml" ;
37+ const cellsApi = BaseTest . initializeCellsApi ( ) ;
38+ const filename = "Book1.xlsx" ;
39+ var data = fs . createReadStream ( localPath + filename ) ;
40+ var req = new model . UploadFileRequest ( ) ;
41+ req . path = "Temp/" + filename ;
42+ req . file = data ;
43+
44+ return cellsApi . uploadFile ( req )
45+ . then ( ( result ) => {
46+ expect ( result . body . uploaded . length ) . greaterThan ( 0 ) ;
47+ const dataFile = "Book1.xlsx" ;
48+ var data = fs . createReadStream ( localPath + dataFile ) ;
49+ var req = new model . UploadFileRequest ( ) ;
50+ req . path = "Temp/" + dataFile ;
51+ req . file = data ;
52+
53+ return cellsApi . uploadFile ( req )
54+ . then ( ( result ) => {
55+ expect ( result . body . uploaded . length ) . greaterThan ( 0 ) ;
56+ var req = new model . CellsWorkbook_PutWorkbookCreateRequest ( ) ;
57+ req . folder = "Temp" ;
58+ var date = new Date ( ) ;
59+ var year = date . getUTCFullYear ( ) ;
60+ var month = date . getUTCMonth ( ) ;
61+ var day = date . getUTCDate ( ) ;
62+ var hours = date . getUTCHours ( ) ;
63+ var min = date . getUTCMinutes ( ) ;
64+ var sec = date . getUTCSeconds ( ) ;
65+ req . name = "NewBook" + year + "" + month + "" + day + "" + hours + "" + min + "" + sec + ".xlsx" ;
66+ req . templateFile = "Temp/Book1.xlsx" ;
67+ req . dataFile = "ReportData.xml" ;
68+
69+ return cellsApi . cellsWorkbookPutWorkbookCreate ( req )
70+ . then ( ( result ) => {
71+ expect ( result . body . code ) . to . equal ( 200 ) ;
72+ expect ( result . response . statusCode ) . to . equal ( 200 ) ;
73+ } ) ;
74+ } ) ;
75+ } ) ;
76+ } ) ;
77+ } ) ;
78+ // describe('cellsWorkbookPutConvertWorkbook', function() {
79+ // it('should call cellsWorkbookPutConvertWorkbook successfully', function() {
80+ // const cellsApi = BaseTest.initializeCellsApi();
81+ // const filename = "Book1.xlsx";
82+ // // var data =fs.createReadStream(localPath + filename);
83+ // var req = new model.CellsWorkbook_PutConvertWorkbookRequest({
84+ // workbook : fs.createReadStream(localPath + filename),
85+ // format : "pdf",
86+ // });
87+
88+ // return cellsApi.cellsWorkbookPutConvertWorkbook(req)
89+ // .then(() => {
90+ // var req = new model.CellsWorkbook_PutConvertWorkbookRequest({
91+ // workbook : fs.createReadStream(localPath + filename),
92+ // format : "pdf",
93+ // });
94+
95+ // return cellsApi.cellsWorkbookPutConvertWorkbook(req)
96+ // .then((result) => {
97+ // expect(result.body.toString().length).to.greaterThan(0);
98+ // });
99+ // });
100+ // });
101+ // });
102+
103+
104+ // describe('cellsSaveAsPostDocumentSaveAs 1', function() {
105+ // it('should call cellsSaveAsPostDocumentSaveAs successfully', function() {
106+ // const cellsApi = BaseTest.initializeCellsApi();
107+ // const filename = "Book1.xlsx";
108+ // var data =fs.createReadStream(localPath + filename);
109+ // var req = new model.UploadFileRequest();
110+ // req.path = "Temp/" + filename;
111+ // req.file = data;
112+
113+ // return cellsApi.uploadFile(req)
114+ // .then(() => {
115+ // var req = new model.CellsSaveAs_PostDocumentSaveAsRequest();
116+ // req.name = filename;
117+ // req.saveOptions = new model.OoxmlSaveOptions();
118+ // req.newfilename = "newbook1.xlsx";
119+ // req.isAutoFitRows = true;
120+ // req.isAutoFitColumns = true;
121+ // req.folder = "Temp";
122+
123+ // return cellsApi.cellsSaveAsPostDocumentSaveAs(req)
124+ // .then((result) => {
125+ // expect(result.body.code).to.equal(200);
126+ // expect(result.response.statusCode).to.equal(200);
127+ // });
128+ // });
129+ // });
130+ // });
131+
132+ // describe('cellsOleObjectsPutWorksheetOleObject', function() {
133+ // it('should call cellsOleObjectsPutWorksheetOleObject successfully', function() {
134+
135+ // const filename = "Book1.xlsx";
136+ // const filename1 = "OLEDoc.docx";
137+ // const filename2 = "word.jpg";
138+ // const cellsApi = BaseTest.initializeCellsApi();
139+ // var data =fs.createReadStream(localPath + filename);
140+ // var req = new model.UploadFileRequest();
141+ // req.path = "Temp/" + filename;
142+ // req.file = data;
143+
144+ // return cellsApi.uploadFile(req)
145+ // .then(() => {
146+ // const filename1 = "word.jpg";
147+ // const cellsApi = BaseTest.initializeCellsApi();
148+ // var data =fs.createReadStream(localPath + filename1);
149+ // var req = new model.UploadFileRequest();
150+ // req.path = "Temp/" + filename1;
151+ // req.file = data;
152+
153+ // return cellsApi.uploadFile(req)
154+ // .then(() => {
155+ // const filename2 = "OLEDoc.docx";
156+ // const cellsApi = BaseTest.initializeCellsApi();
157+ // var data =fs.createReadStream(localPath + filename2);
158+ // var req = new model.UploadFileRequest();
159+ // req.path = "Temp/" + filename2;
160+ // req.file = data;
161+
162+ // return cellsApi.uploadFile(req)
163+ // .then(() => {
164+ // var req = new model.CellsOleObjects_PutWorksheetOleObjectRequest();
165+ // req.name = filename;
166+ // req.sheetName = "Sheet6";
167+ // req.folder = "Temp";
168+ // req.oleObject = null;
169+ // req.upperLeftRow = 1;
170+ // req.upperLeftColumn = 1;
171+ // req.height = 100;
172+ // req.width = 80;
173+ // req.oleFile = filename1;
174+ // req.imageFile = filename2;
175+
176+ // return cellsApi.cellsOleObjectsPutWorksheetOleObject(req)
177+ // .then((result) => {
178+ // expect(result.body.code).to.equal(200);
179+ // expect(result.response.statusCode).to.equal(200);
180+ // });
181+ // });
182+ // });
183+ // });
184+ // });
185+ // });
186+
187+
188+
189+ // describe('cellsChartsGetWorksheetChartTitle', function() {
190+ // it('should call cellsChartsGetWorksheetChartTitle successfully', function() {
191+ // const cellsApi = BaseTest.initializeCellsApi();
192+ // const filename = "Book1.xlsx";
193+ // var data =fs.createReadStream(localPath + filename);
194+ // var req = new model.UploadFileRequest();
195+ // req.path = "Temp/" + filename;
196+ // req.file = data;
197+
198+ // return cellsApi.uploadFile(req)
199+ // .then(() => {
200+ // var req = new model.CellsCharts_GetWorksheetChartTitleRequest();
201+ // req.name = filename;
202+ // req.sheetName = "Sheet4";
203+ // req.chartIndex = 0;
204+ // req.folder = "Temp";
205+
206+ // return cellsApi.cellsChartsGetWorksheetChartTitle(req)
207+ // .then((result) => {
208+ // expect(result.body.code).to.equal(200);
209+ // expect(result.response.statusCode).to.equal(200);
210+ // });
211+ // });
212+ // });
213+ // });
214+
215+
216+ // describe('CellsWorkbookApi', function() {
217+ // this.timeout(20000);
218+ // describe('cellsWorkbookPutConvertWorkbook', function() {
219+ // it('should call cellsWorkbookPutConvertWorkbook successfully', function() {
220+ // const cellsApi = BaseTest.initializeCellsApi();
221+ // const filename = "Book1.xlsx";
222+ // var req = new model.UploadFileRequest();
223+ // req.path = "Temp/" + filename;
224+ // req.file = fs.readFileSync(localPath + filename);
225+ // return new Promise((resolve) => {
226+ // cellsApi.uploadFile(req);
227+ // resolve();
228+ // })
229+ // .then(() => {
230+ // // var req = new model.CellsWorkbook_PutConvertWorkbookRequest();
231+ // // req.workbook = fs.readFileSync(localPath + filename);
232+ // // req.format = "pdf";
233+ // var req = new model.CellsWorkbook_PutConvertWorkbookRequest({
234+ // workbook : fs.readFileSync(localPath + filename),
235+ // format : "pdf",
236+ // });
237+
238+ // return cellsApi.cellsWorkbookPutConvertWorkbook(req)
239+ // .then((result) => {
240+ // expect(result.body.toString().length).to.greaterThan(0);
241+ // });
242+ // });
243+ // });
244+ // });
245+ // });
0 commit comments