Pubblico API Modifiche Aspose.Cells 8.7.0

API aggiunte

Supporto per la firma digitale, il rilevamento e l’estrazione del progetto VBA

Questa versione di Aspose.Cells for .NET ha esposto alcune nuove proprietà e metodi per aiutare gli utenti in attività come la firma digitale di un progetto VBA, rilevando se un progetto VBA è firmato e valido. Inoltre, il nuovo API consente di estrarre il certificato come dati grezzi dal progetto VBA firmato digitalmente in Workbook.

Firma digitalmente progetto VBA

Aspose.Cells for .NET 8.7.0 ha esposto il metodo VbaProject.Sign che può essere utilizzato perfirmare digitalmente il progetto VBA in una cartella di lavoro. Detto metodo accetta un’istanza della classe DigitalSignature che risiede nel namespace Aspose.Cells.DigitalSignatures.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook

//Optionally load an existing spreadsheet

var book = new Workbook();

//Access the VbaProject from the Workbook

var vbaProject = book.VbaProject;

//Sign the VbaProject using the X509Certificate

vbaProject.Sign(new DigitalSignature(new System.Security.Cryptography.X509Certificates.X509Certificate2(cert), "Comments", DateTime.Now));
Rilevamento del progetto VBA con firma digitale

È possibile utilizzare la proprietà VbaProject.IsSigned appena espostarilevare se il progetto VBA in una cartella di lavoro è firmato digitalmente. La proprietà VbaProject.IsSigned è di tipo Boolean, che restituisce true se il progetto VBA è firmato digitalmente e viceversa.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook and load an existing spreadsheet

var book = new Workbook(inFilePath);

//Access the VbaProject from the Workbook

var vbaProject = book.VbaProject;

//Check if VbaProject is digitally signed

if (vbaProject.IsSigned)

{

    Console.WriteLine("VbaProject is digitally signed");

}

else

{

    Console.WriteLine("VbaProject is not digitally signed");

}
Estrazione della Firma Digitale dal Progetto VBA

Questa revisione della API ha esposto anche la proprietà VbaProject.CertRawData che permette diestrarre i dati grezzi del certificato digitale dal progetto VBA. La proprietà VbaProject.CertRawData è di tipo byte array, che conterrà i dati grezzi del certificato se il progetto VBA è firmato digitalmente, altrimenti tale proprietà sarà nulla.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook and load an existing spreadsheet

var book = new Workbook(inFilePath);

//Access the VbaProject from the Workbook

var vbaProject = book.VbaProject;

//Extract digital signature in an array of bytes

var cert = vbaProject.CertRawData;
Convalida la Firma Digitale del Progetto VBA

Un’altra aggiunta al pubblico API è la proprietà VbaProject.IsValidSigned che potrebbe essere utile inconvalidare la firma digitale del progetto VBA. La suddetta proprietà restituisce true se la firma digitale è valida e false se la firma non è valida.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook and load an existing spreadsheet

var book = new Workbook(inFilePath);

//Access the VbaProject from the Workbook

var vbaProject = book.VbaProject;

//Check if VbaProject is digitally signed

if (vbaProject.IsSigned)

{

    //Check if signature is valid

    if (vbaProject.IsValidSigned)

    {

        Console.WriteLine("VbaProject is digitally signed & signature is valid");

    }

}

Metodo Protection.VerifyPassword aggiunto

Aspose.Cells for .NET 8.7.0 ha esposto il metodo Protection.VerifyPassword che può essere utilizzato perverificare la password utilizzata per proteggere il foglio di lavoroQuesto metodo accetta un’istanza di string come parametro e restituisce true se la password specificata corrisponde alla password utilizzata per proteggere il foglio di lavoro.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook and load an existing spreadsheet

var book = new Workbook(inFilePath);

//Access the desired Worksheet via its index or name

var sheet = book.Worksheets[0];

//Access Protection module of desired Worksheet

var protection = sheet.Protection;

//Verify the password for Worksheet

if (protection.VerifyPassword(password))

{

    Console.WriteLine("Password has matched");

}

else

{

    Console.WriteLine("Password did not match");

}

Proprietà Protection.IsProtectedWithPassword aggiunto

Questa versione di Aspose.Cells for .NET API ha esposto anche la proprietà Protection.IsProtectedWithPassword che può essere utile inrilevare se un foglio di lavoro è protetto da password o meno.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook and load an existing spreadsheet

var book = new Workbook(inFilePath);

//Access the desired Worksheet via its index or name

var sheet = book.Worksheets[0];

//Access Protection module of desired Worksheet

var protection = sheet.Protection;

//Check if Worksheet is password protected

if (protection.IsProtectedWithPassword)

{

    Console.WriteLine("Worksheet is password protected");

}

else

{

    Console.WriteLine("Worksheet is not password protected");

}

Proprietà ColorScale.Is3ColorScale Aggiunta

Aspose.Cells for .NET 8.7.0 ha esposto la proprietà ColorScale.Is3ColorScale che può essere utilizzata per creare il formato condizionale Scala a 2 colori. La suddetta proprietà è di tipo Boolean con valore predefinito true, il che significa che il formato condizionale sarà di default Scala a 3 colori. Tuttavia, il passaggio della proprietà ColorScale.Is3ColorScale a false lo faràgenerare un formato condizionale Scala a 2 colori.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook

//Optionally load an existing spreadsheet

var book = new Workbook();

//Access the Worksheet to which conditional formatting rule has to be added

var sheet = book.Worksheets[0];

//Add FormatConditions to the collection

int index = sheet.ConditionalFormattings.Add();

//Access newly added formatConditionCollection via its index

var formatConditionCollection = sheet.ConditionalFormattings[index];

//Create a CellArea on which conditional formatting rule will be applied

var cellArea = CellArea.CreateCellArea("A1", "A5");

//Add conditional formatted cell range

formatConditionCollection.AddArea(cellArea);

//Add format condition of type ColorScale

index = formatConditionCollection.AddCondition(FormatConditionType.ColorScale);

//Access newly added format condition via its index

var formatCondition = formatConditionCollection[index];

//Set Is3ColorScale to false in order to generate a 2-Color Scale format

formatCondition.ColorScale.Is3ColorScale = false;

//Set other necessary properties

Proprietà TxtLoadOptions.HasFormula aggiunto

Aspose.Cells for .NET 8.7.0 ha fornito supporto aidentificare e analizzare le formule durante il caricamento di file CSV/TXT con dati semplici delimitati. La proprietà TxtLoadOptions.HasFormula appena esposta quando impostata su true indica a API di analizzare le formule dal file delimitato di input e di impostarle sulle celle pertinenti senza richiedere alcuna elaborazione aggiuntiva.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of TxtLoadOptions

var options = new TxtLoadOptions();

//Set HasFormula property to true

options.HasFormula = true;

//Set the Separator property as desired

options.Separator = ',';

//Load the CSV/TXT file using the instance of TxtLoadOptions

var book = new Workbook(inFilePath, options);

//Calculate formulas in order to get the calculated values of formula in CSV

book.CalculateFormula();

//Write result in any of the supported formats

book.Save(outFilePath);

Proprietà DataLabels.IsResizeShapeToFitText Aggiunta

Un’altra caratteristica utile che Aspose.Cells for .NET 8.7.0 ha esposto è la proprietà DataLabels.IsResizeShapeToFitText che può abilitare ilRidimensiona la forma per adattarla al testofunzionalità dell’applicazione Excel per le etichette dei dati del grafico.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of Workbook containing the Chart

var book = new Workbook(inFilePath);

//Access the Worksheet that contains the Chart

var sheet = book.Worksheets[0];

//Access the desired Chart via its index or name

var chart = sheet.Charts[0];

//Access the DataLabels of desired NSeries

var labels = chart.NSeries[0].DataLabels;

//Set ResizeShapeToFitText property to true

labels.IsResizeShapeToFitText = true;

//Calculate Chart

chart.Calculate();

Proprietà PdfSaveOptions.OptimizationType aggiunta

Aspose.Cells for .NET 8.7.0 ha esposto la proprietà PdfSaveOptions.OptimizationType insieme all’enumerazione PdfOptimizationType per facilitare agli utentiscegli l’algoritmo di ottimizzazione desiderato durante l’esportazione dei fogli di calcolo nel formato PDF. Esistono 2 valori possibili per la proprietà PdfSaveOptions.OptimizationType come descritto di seguito.

  1. PdfOptimizationType.MinimumSize: la qualità è compromessa per la dimensione del file risultante.
  2. PdfOptimizationType.Standard: la qualità non è compromessa quindi la dimensione del file risultante sarà grande.

Di seguito è riportato il semplice scenario di utilizzo.

C#

 //Create an instance of PdfSaveOptions

var pdfSaveOptions = new PdfSaveOptions();

//Set the OptimizationType property to desired value

pdfSaveOptions.OptimizationType = PdfOptimizationType.MinimumSize;

//Create an instance of Workbook

//Optionally load an existing spreadsheet

var book = new Workbook(inFilePath);

//Save the spreadsheet in PDF format while passing the instance of PdfSaveOptions

book.Save(outFilePath, pdfSaveOptions);

API rimosse

Proprietà Workbook.SaveOptions Rimosso

La proprietà Workbook.SaveOptions è stata contrassegnata come obsoleta qualche tempo fa. Con questa release è stato completamente rimosso dal pubblico API pertanto si consiglia di utilizzare in alternativa il metodo Workbook.Save(Stream, SaveOptions) o Workbook.Save(string, SaveOptions).