Пример #1
0
        public static void Run()
        {
            // ExStart:1
            CellsApi   cellsApi   = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName             = "Sample_Test_Book.xls";
            String sheetName            = "Sheet1";
            String storage              = "";
            String folder               = "";
            WorksheetMovingRequest body = new WorksheetMovingRequest();

            body.DestinationWorksheet = "Sheet5";
            body.Position             = "after";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Cells Cloud SDK API to move excel worksheets
                WorksheetsResponse apiResponse = cellsApi.PostMoveWorksheet(fileName, sheetName, storage, folder, body);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    Console.WriteLine("WorkSheet moved!");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
Пример #2
0
        public static void Run()
        {
            // ExStart:1
            CellsApi   cellsApi   = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName  = "Sample_Test_Book.xls";
            String sheetName = "Sheet2-new";
            String storage   = "";
            String folder    = "";

            try
            {
                // Invoke Aspose.Cells Cloud SDK API to add new excel sheet
                WorksheetsResponse apiResponse = cellsApi.PutAddNewWorksheet(fileName, sheetName, storage, folder);

                if (apiResponse != null)
                {
                    Console.WriteLine("Added a New Excel Worksheet!");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            CellsApi   cellsApi   = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName = "Sample_Test_Book.xls";
            String storage  = "";
            String folder   = "";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Words Cloud SDK API to get worksheet count
                WorksheetsResponse apiResponse = cellsApi.GetWorkSheets(fileName, storage, folder);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    Console.WriteLine("Sheet Count: " + apiResponse.Worksheets.WorksheetList.Count);
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
        static void Main()
        {
            string dataDir = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            string input = "sample1.xlsx";

            //string output = "ouput.xlsx";

            Common.StorageService.File.UploadFile(dataDir + input, input, storage: Common.STORAGE);

            WorksheetsResponse apiResponse = Common.CellsService.Worksheets.ReadWorksheetsInfo(input, Common.FOLDER, storage: Common.STORAGE);

            Console.WriteLine(" Respoonse: " + apiResponse.Worksheets.WorksheetList.Count);
        }
        public void Cells_Worksheets_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx");

                WorksheetsResponse WorksheetsResponse = cellsService.Worksheets.ReadWorksheetsInfo(name, Utils.CloudStorage_Output_Folder);
                WorksheetResponse  ReadWorksheetInfo  = cellsService.Worksheets.ReadWorksheetInfo(name, "sheet2", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.ExportWorksheet(name, "sheet1", WorksheetExportFormat.Gif, 0, 0, Utils.CloudStorage_Output_Folder, Utils.Local_Output_Path + "cells_worksheet_gif.gif");

                cellsService.Worksheets.AddNewWorksheet(name, "sheetZ", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheet(name, "sheetZ", Utils.CloudStorage_Output_Folder);

                ReadWorksheetInfo.Worksheet.IsSelected = true;
                WorksheetResponse WorksheetResponse = cellsService.Worksheets.UpdateWorksheetProperty(name, "sheet2", ReadWorksheetInfo.Worksheet, Utils.CloudStorage_Output_Folder);

                WorksheetResponse WorksheetResponse2 = cellsService.Worksheets.ChangeWorksheetVisibility(name, "sheet1", false, Utils.CloudStorage_Output_Folder);
                WorksheetResponse WorksheetResponse3 = cellsService.Worksheets.ChangeWorksheetVisibility(name, "sheet1", true, Utils.CloudStorage_Output_Folder);

                CellsMoveWorksheetRequest cellsMoveWorksheetRequest = new CellsMoveWorksheetRequest();
                cellsMoveWorksheetRequest.DestinationWorksheet = "sheet3";
                cellsMoveWorksheetRequest.Position             = 3;

                cellsService.Worksheets.MoveWorksheet(name, "sheet1", cellsMoveWorksheetRequest, Utils.CloudStorage_Output_Folder);

                CellsProtectParameter cellsProtectParameter = new CellsProtectParameter(CellsProtectionType.All);
                cellsProtectParameter.Password = "******";
                cellsService.Worksheets.ProtectWorksheet(name, "sheet1", cellsProtectParameter, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.UnprotectWorksheet(name, "sheet1", cellsProtectParameter, Utils.CloudStorage_Output_Folder);

                CellsTextItemsResponse CellsTextItemsResponse = cellsService.Worksheets.GetWorksheetTextItems(name, "sheet1", Utils.CloudStorage_Output_Folder);

                CellsCommentRequest cellsCommentRequest = new CellsCommentRequest();
                cellsCommentRequest.Note      = "Aspose.Cells for .NET";
                cellsCommentRequest.IsVisible = true;
                cellsCommentRequest.CellName  = "A1";
                cellsCommentRequest.Width     = 100;
                cellsCommentRequest.Height    = 50;

                cellsService.Worksheets.AddWorksheetsCellComment(name, "sheet1", "A1", cellsCommentRequest, Utils.CloudStorage_Output_Folder);

                CellsCommentsResponse CellsCommentsResponse = cellsService.Worksheets.GetWorksheetComments(name, "sheet1", Utils.CloudStorage_Output_Folder);
                CellsCommentResponse  CellsCommentResponse  = cellsService.Worksheets.GetWorksheetCommentByCellName(name, "sheet1", "A1", Utils.CloudStorage_Output_Folder);

                cellsCommentRequest.Author = "Aspose";
                cellsService.Worksheets.UpdateWorksheetsCellComment(name, "sheet1", "A1", cellsCommentRequest, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheetsCellComment(name, "sheet1", "A1", Utils.CloudStorage_Output_Folder);

                MergedCellsResponse MergedCellsResponse = cellsService.Worksheets.GetWorksheetMergedCells(name, "sheet1", Utils.CloudStorage_Output_Folder);
                MergedCellResponse  MergedCellResponse  = cellsService.Worksheets.GetWorksheetMergedCellByItsIndex(name, "sheet1", 0, Utils.CloudStorage_Output_Folder);

                CellsForumulaValueResponse    CellsForumulaValueResponse    = cellsService.Worksheets.CalculateFormulaValue(name, "sheet1", "D5*E5", Utils.CloudStorage_Output_Folder);
                CellsTextItemsResponse        CellsTextItemsResponse2       = cellsService.Worksheets.SearchText(name, "sheet1", "Student1", Utils.CloudStorage_Output_Folder);
                CellsWorksheetMatchesResponse CellsWorksheetMatchesResponse = cellsService.Worksheets.ReplaceText(name, "sheet1", "Student", "Employee", Utils.CloudStorage_Output_Folder);

                CellsDataSorterRequest dataSorter = new CellsDataSorterRequest();
                dataSorter.CaseSensitive = true;
                dataSorter.HasHeaders    = true;

                CellsKeyList cellsKeyList = new CellsKeyList();
                cellsKeyList.Key       = 1;
                cellsKeyList.SortOrder = "DESCENDING";

                dataSorter.KeyList = new List <CellsKeyList>();
                dataSorter.KeyList.Add(cellsKeyList);

                cellsService.Worksheets.SortWorksheetRange(name, "sheet1", "B4:F19", dataSorter, Utils.CloudStorage_Output_Folder);

                CellsAutoFitterOptionsRequest autoFitterOptions = new CellsAutoFitterOptionsRequest();
                autoFitterOptions.OnlyAuto = true;
                cellsService.Worksheets.AutofitWorksheetRows(name, "sheet1", 1, 100, true, autoFitterOptions, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.SetWorksheetBackgroundImage(name, "sheet1", Utils.Local_Input_Path + "signature.jpg", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheetBackgroundImage(name, "sheet1", Utils.CloudStorage_Output_Folder);

                cellsService.Worksheets.SetFreezePanes(name, "sheet1", 4, 1, 1, 1, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.UnfreezePanes(name, "sheet1", 4, 1, 1, 1, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.CopyWorksheet(name, "sheetZ", "sheet1", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.RenameWorksheet(name, "sheetZ", "sheetRenamed", Utils.CloudStorage_Output_Folder);

                //storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx", Utils.Local_Output_Path + "/cells-sample.xlsx");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }