Aplicar formato de texto enriquecido a una celda Este REST API indica aplicar rich text formatting
a una celda en un archivo Excel.
RSET API
Copy
POST http://api.aspose.cloud/v3.0/cells/{ name} /worksheets/{ sheetName} /cells/{ cellName} /characters
Los parámetros de la solicitud son:
Nombre del parámetro
Tipo
Ruta/Cadena de consulta/Cuerpo HTTP
Descripción
nombre
cadena
camino
nombre de la hoja
cadena
camino
nombre de celda
cadena
camino
opciones
cuerpo
carpeta
cadena
consulta
nombredealmacenamiento
cadena
consulta
nombre del almacenamiento.
ElEspecificación de API abierta define una interfaz de programación de acceso público y le permite realizar interacciones REST directamente desde un navegador web.
Puede utilizar la herramienta de línea de comandos cURL para acceder fácilmente a los servicios web Aspose.Cells. El siguiente ejemplo muestra cómo realizar llamadas a Cloud API con cURL.
Familia de SDK en la nube
Usar un SDK es la mejor manera de acelerar el desarrollo. Un SDK se encarga de los detalles de bajo nivel y le permite concentrarse en las tareas de su proyecto. Por favor revisa elrepositorio de GitHub para obtener una lista completa de Aspose.Cells SDK de nube.
Los siguientes ejemplos de código demuestran cómo realizar llamadas a servicios web Aspose.Cells utilizando varios SDK:
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
namespace Aspose.Cells.Cloud.SDK.Example
{
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Model;
using Aspose.Cells.Cloud.SDK.Request;
using System;
using System.Collections.Generic;
public partial class CellsApiExample
{
public void PostCellCharactersExample()
{
CellsApi cellsApi = new CellsApi(Environment.GetEnvironmentVariable("CellsCloudTestClientId"), Environment.GetEnvironmentVariable("CellsCloudTestClientSecret"));
List<FontSetting> options = new List<FontSetting>();
Font font = new Font();
font.Size = 10;
FontSetting fs1 = new FontSetting();
fs1.Font = font;
fs1.Length = 2;
fs1.StartIndex = 0;
options.Add(fs1);
PostCellCharactersRequest request = new PostCellCharactersRequest { name = "Book1.xlsx", sheetName ="Sheet1", cellName ="A1", options = options, folder = "TestData/In" };
cellsApi.PostCellCharacters(request);
}
}
}
// Obsolet
//CellsApi instance = new CellsApi(clientId, clientSecret, apiVersion, testbaseurl);
//string name = BOOK1;
//string sheetName = SHEET2;
//string cellName = "G8";
//List<FontSetting> options = new List<FontSetting>();
//Font font = new Font();
//font.Size = 10;
//FontSetting fs1 = new FontSetting();
//fs1.Font = font;
//fs1.Length = 2;
//fs1.StartIndex = 0;
//options.Add(fs1);
//string folder = TEMPFOLDER;
//instance.UploadFile(folder + @"\" + name, File.Open( @"C:\TestData\" +name));
//var response = instance.CellsPostCellCharacters(name, sheetName, cellName, options, folder);
//Assert.IsInstanceOf<CellsCloudResponse>(response, "response is CellsCloudResponse");
//Assert.AreEqual(response.Status, "OK");
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-php
<?php
require_once('vendor\autoload.php');
use \Aspose\Cells\Cloud\Api\CellsApi;
use \Aspose\Cells\Cloud\Request\PostCellCharactersRequest;
class Cell {
public $instance;
public function __construct() {
$this->instance = new CellsApi(getenv("CellsCloudClientId"),getenv("CellsCloudClientSecret"),"v3.0",getenv("CellsCloudApiBaseUrl"));
}
public function postCellTextFormatting() {
$remoteFolder = "TestData/In";
$localName = "Book1.xlsx";
$remoteName = "Book1.xlsx";
$optionsvalue0Font = new \Aspose\Cells\Cloud\Model\Font();
$optionsvalue0Font->setIsBold('true' );
$optionsvalue0Font->setSize(16 );
$optionsvalue0 = new \Aspose\Cells\Cloud\Model\FontSetting();
$optionsvalue0->setLength(5 );
$optionsvalue0->setStartIndex(0 );
$optionsvalue0->setFont($optionsvalue0Font );
$options = array (
$optionsvalue0
);
$request = new PostCellCharactersRequest();
$request->setName( $remoteName);
$request->setSheetName( "Sheet1");
$request->setCellName( "E36");
$request->setOptions( $options);
$request->setFolder( $remoteFolder);
$request->setStorageName( "");
$this->instance->postCellCharacters($request);
}
}
$instance = new Cell();
$instance->postCellTextFormatting();
?>
Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-ruby
require 'aspose_cells_cloud'
class Cell
include AsposeCellsCloud
def initialize
#Get client_id and client_secret from https://cloud.aspose.com
@instance = AsposeCellsCloud::CellsApi.new($client_id,$client_secret,$api_version,$baseurl)
end
def upload_file(file_name)
response = @cells_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Rich text formatting in a single cell.
def post_cell_text_formatting
file_name = "Book1.xlsx"
upload_file(file_name)
sheet_name = "sheet1"
cell_name = "A1"
# Set cell value
response = @cells_api.post_worksheet_cell_set_value(file_name, sheet_name, cell_name, {value: "121211212112", type: "string"})
fontSetting1 = FontSetting.new
fontSetting1.length = 5
fontSetting1.start_index = 0
font1 = Font.new
font1.is_bold = true
font1.size = 24
fontSetting1.font = font1
fontSetting2 = FontSetting.new
fontSetting2.length = 4
fontSetting2.start_index = 5
font2 = Font.new
font2.is_italic = true
font2.size = 15
fontSetting2.font = font2
options = [fontSetting1, fontSetting2]
# Rich text formatting in a single cell
response = @cells_api.post_cell_text_formatting(file_name, sheet_name, cell_name, options, opts = {})
end
end
cell = Cell.new()
puts cell.post_cell_text_formatting
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-node/
const { CellsApi,UploadFileRequest, Cells_PostCellCharactersRequest,Font ,FontSetting } = require("asposecellscloud");
const clientId = process.env.CellsCloudClientId;
const clientSecret = process.env.CellsCloudClientSecret;
const ApiURL = process.env.CellsCloudApiBaseUrl;
const CellsApi = new CellsApi(clientId, clientSecret,"v3.0",ApiURL);
const fs = require('fs');
const path = require('path');
const localPath = "D:/aspose-cells-cloud-node/TestData/"
const filename = "Book1.xlsx";
const data =fs.createReadStream(path.join(localPath, filename));
const req = new model.UploadFileRequest();
req.path = "Temp/" + filename;
req.file = data;
CellsApi.uploadFile(req)
.then((result) => {
const req = new model.Cells_PostCellCharactersRequest();
req.name = filename;
req.cellName = "G8";
req.sheetName = "Sheet2";
req.folder = "Temp";
const font = new Font();
font.size = 10;
const fs1 = new FontSetting();
fs1.font = font;
fs1.length = 2;
fs1.startIndex = 0;
const options = new Array<FontSetting>();
options.push(fs1);
req.options = options;
cellsApi.cellsPostCellCharacters(req)
.then((result) => {
console.log("successfully");
});
})
.catch((error) => {
console.error('Unhandled Promise Rejection:', error);
});
Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-perl/
use strict;
use warnings;
use utf8;
use File::Slurp;
use MIME::Base64;
use AsposeCellsCloud::CellsApi;
my $config = AsposeCellsCloud::Configuration->new( client_id => $ENV{'ProductClientId'}, client_secret => $ENV{'ProductClientSecret'});
my $instance = AsposeCellsCloud::CellsApi->new(AsposeCellsCloud::ApiClient->new( $config));
my $remoteFolder = 'TestData/In';
my $remoteName = 'Book1.xlsx';
my $optionsvalue0_font = AsposeCellsCloud::Object::Font->new();
$optionsvalue0_font->{is_bold} = 'true' ;
$optionsvalue0_font->{size} = 16 ;
my $optionsvalue0 = AsposeCellsCloud::Object::FontSetting->new();
$optionsvalue0->{length} = 5 ;
$optionsvalue0->{start_index} = 0 ;
$optionsvalue0->{font} = $optionsvalue0_font ;
my @options = [];push (@options ,$optionsvalue0 );
my $request = AsposeCellsCloud::Request::PostCellCharactersRequest->new();
$request->{name} = $remoteName;
$request->{sheet_name} = 'Sheet1';
$request->{cell_name} = 'E36';
$request->{options} = []; push ( @{$request->{options}}, $optionsvalue0 );;
$request->{folder} = $remoteFolder;
$request->{storage_name} = '';
my $result = $api->post_cell_characters(request=> $request);
Go