Solution.Framework.Office 7.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Solution.Framework.Office --version 7.0.3                
NuGet\Install-Package Solution.Framework.Office -Version 7.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Solution.Framework.Office" Version="7.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Solution.Framework.Office --version 7.0.3                
#r "nuget: Solution.Framework.Office, 7.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Solution.Framework.Office as a Cake Addin
#addin nuget:?package=Solution.Framework.Office&version=7.0.3

// Install Solution.Framework.Office as a Cake Tool
#tool nuget:?package=Solution.Framework.Office&version=7.0.3                

Office Nuget

Office Framework

Sample code

ExcelClass
using Solution.Framework.Office;
using System;
using System.Data;
using System.IO;

namespace ConsoleApp.FrameworkOffice
{
    class Program
    {
        static void Main(string[] args)
        {
            string filePath = @"C:\Temp\Test.xlsx";

            DataSet ds = GetDataSet();

            // 1
            ExcelClass.Export(filePath, ds);

            // 2
            byte[] xlsx = ExcelClass.Export(ds);
        }

        private DataSet GetDataSet()
        {
            DataSet ds = new();
            DataTable dt = new("Table1");

            for (int i = 0; i <= 100; i++)
            {
                dt.Columns.Add(new DataColumn($"Header.{i}"));
            }

            for (int i = 1; i <= 100; i++)
            {
                DataRow dr = dt.NewRow();
                for (int c = 0; c <= 100; c++)
                {
                    dr[$"Header.{c}"] = $"Col{c}." + i.ToString();
                }
                dt.Rows.Add(dr);
            }
            ds.Tables.Add(dt);

            dt = new DataTable("Table2");

            for (int i = 0; i <= 100; i++)
            {
                dt.Columns.Add(new DataColumn($"Header.{i}"));
            }

            for (int i = 1; i <= 100; i++)
            {
                DataRow dr = dt.NewRow();
                for (int c = 0; c <= 100; c++)
                {
                    dr[$"Header.{c}"] = $"Col{c}." + i.ToString();
                }
                dt.Rows.Add(dr);
            }
            ds.Tables.Add(dt);

            return ds;
        }
    }
}
OutlookClass
{
  "EmailConfigurations": {
    "SmtpServer": "smtp",
    "SmtpPort": 587,
    "SmtpUser": "email",
    "SmtpPassword": "password",
    "EnableSsl": true,
    "UseDefaultCredentials": false,
    "Timeout": 60,
    "ToTest": "",
    "CCTest": "",
    "CCOTest": "",
    "SubjectTest": "",
    "BodyTest": ""
  }
}
using Microsoft.Extensions.Configuration;
using Solution.Framework.Office.Helpers;
using Solution.Framework.Office.Models;
using Solution.Framework.Office.Test.Classes;
using System.Collections.Generic;

namespace ConsoleApp.FrameworkOffice
{
    class Program
    {
        static void Main(string[] args)
        {
            OutlookClass.Configuration = GetConfiguration();

            // 1
            OutlookClass.Send("email", "Email Test", "Test");

            // 2
            OutlookClass.Send("email", "Email Test", GetBody());
        }

        private static IConfiguration GetConfiguration()
        {
            string path = "appsettings.json";
            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json"))
            {
                path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json";
            }
            return new ConfigurationBuilder().AddJsonFile(path).Build();
        }

        private Dictionary<string, EmailParameter[]> GetBody()
        {
            Dictionary<string, EmailParameter[]> pairs = new();

            ElementTable[] sourceData = new[]
                {
                    new ElementTable { Nome = "Name1", Valor = 100.30M },
                    new ElementTable { Nome = "Name2", Valor = 300.56M },
                    new ElementTable { Nome = "Name3", Valor = 140.30M }
                };

            string html = sourceData.ToHtmlTable();

            EmailParameter[] parameters = new[]
                {
                    new EmailParameter { Name = "Parameter1", Value = "Test Parameter"},
                    new EmailParameter { Name = "Parameter2", Value = "Office"},
                    new EmailParameter { Name = "tables", Value = html }
                };

            pairs.Add(@"<h2>E-mail Test {{Parameter1}}</h2>
                        <p>&nbsp;</p>
                        <p>This email is a test for framework {{Parameter2}}</p>
                        {{tables}}", parameters);

            return pairs;
        }
    }
}
SftpClass
{
  "SftpConfigurations": {
    "Host": "host",
    "Port": 123,
    "UserName": "user name",
    "Password": "password"
  }
}
using Solution.Framework.Office;
using System;
using System.Data;
using System.IO;

namespace ConsoleApp.FrameworkOffice
{
    class Program
    {
        static void Main(string[] args)
        {
            List<SftpResponse> result = StfpClass.SendFile(GetConfiguration(), "fileName", "sourcePath", "destinationPath", "privateKeyFile")

            List<SftpResponse> result = StfpClass.ReceiveFile(GetConfiguration(), "fileName", "sourcePath", "destinationPath", "privateKeyFile")
        }

        private static IConfiguration GetConfiguration()
        {
            string path = "appsettings.json";
            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json"))
            {
                path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json";
            }
            return new ConfigurationBuilder().AddJsonFile(path).Build();
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 112 2/15/2024
7.0.3 143 9/16/2023
7.0.2 143 9/8/2023
7.0.1 141 9/3/2023
7.0.0 281 1/24/2023
6.0.1 405 7/28/2022
6.0.0 389 7/27/2022
5.0.1 322 11/11/2021
5.0.0 336 10/12/2021