Info
Version: | 1.0.0.118 |
Author(s): | Bruno N. Fernandes |
Last Update: | Sunday, November 6, 2022 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://github.com/Bruno-N-Fernandes/MPSC.PlenoSoft.Office.PlenoExcel |
NuGet Url: | https://www.nuget.org/packages/MPSC.PlenoSoft.Office.PlenoExcel |
Install
Install-Package MPSC.PlenoSoft.Office.PlenoExcel
dotnet add package MPSC.PlenoSoft.Office.PlenoExcel
paket add MPSC.PlenoSoft.Office.PlenoExcel
MPSC.PlenoSoft.Office.PlenoExcel Download (Unzip the "nupkg" after downloading)
Dependencies
- DocumentFormat.OpenXml(>= 2.7.2)
Tags
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MPSC.PlenoSoft.Office.Planilhas.Controller;
using MPSC.PlenoSoft.Office.Planilhas.Integracao;
using MPSC.PlenoSoft.Office.Planilhas.Util;
namespace MPSC.PlenoSoft.Office.Testes.Unidade
{
[TestClass]
public class TestandoGeradorDePlanilha
{
private static readonly String cRoot = File.Exists(@"C:\Temp\") ? @"C:\Temp" : Path.GetTempPath();
[TestMethod]
public void Quando_Converte0()
{
var leads = new List<Lead>();
for (int i = 0; i < 10; i++)
{
var lead = new Lead { Properties = i };
leads.Add(lead);
}
var arquivo = new FileInfo(cRoot + @"\OfficeDTO.xlsx");
var plenoExcel = new PlenoExcel(arquivo, Modo.Padrao | Modo.ApagarSeExistir);
plenoExcel.Exportar(leads);
plenoExcel.Fechar();
}
[TestMethod]
public void Quando_Grava_Uma_Planilha_Excel()
{
var arquivoExcel = new FileInfo(cRoot + @"\PlenoExcel.xlsx");
var plenoExcel = new PlenoExcel(arquivoExcel, Modo.Seguro | Modo.SempreCriaNovo);
var plan1 = plenoExcel["Plan1"];
plan1.Escrever("A", 1, "Numero 1", Style.Header);
plan1.Escrever("B", 1, "Número 2", Style.Header);
plan1.Escrever("C", 1, "Soma", Style.Header);
plan1.Escrever("A", 2, 6, Style.Geral);
plan1.Escrever("B", 2, 4, Style.Geral);
plan1.Escrever("C", 2, "=SUM(A2:B2)", Style.Geral);
plenoExcel.Salvar();
plenoExcel.Fechar();
}
[TestMethod]
public void Exemplo_De_Como_Gerar_Uma_Planilha_Excel_A_Partir_De_Uma_Lista_De_DTOs()
{
var arquivoExcel = new FileInfo(@"C:\Temp\PlenoExcel.xlsx");
var plenoExcel = new PlenoExcel(arquivoExcel, Modo.Padrao | Modo.ApagarSeExistir);
plenoExcel.Exportar(listaDTO);
plenoExcel.Fechar();
}
}
}.