FileConversionLibrary 1.3.0

dotnet add package FileConversionLibrary --version 1.3.0
                    
NuGet\Install-Package FileConversionLibrary -Version 1.3.0
                    
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="FileConversionLibrary" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FileConversionLibrary" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="FileConversionLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FileConversionLibrary --version 1.3.0
                    
#r "nuget: FileConversionLibrary, 1.3.0"
                    
#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.
#:package FileConversionLibrary@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FileConversionLibrary&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=FileConversionLibrary&version=1.3.0
                    
Install as a Cake Tool

File Conversion Library

Image 1

This library provides functionality to convert CSV and XML files to various formats such as XML, PDF, Word, JSON, and YAML.

Usage

Initializing the FileConverter

To use the library, you need to create an instance of the FileConverter class.

// Create a new instance of the FileConverter
var fileConverter = new FileConverter();

CSV to XML Conversion

await fileConverter.ConvertCsvToXmlAsync(
    @"C:\Users\User\Desktop\input.csv",
    @"C:\Users\User\Desktop\output.xml"
);

CSV to PDF Conversion

await fileConverter.ConvertCsvToPdfAsync(
    @"C:\Users\User\Desktop\input.csv",
    @"C:\Users\User\Desktop\output.pdf"
);

CSV to Word Conversion

await fileConverter.ConvertCsvToWordAsync(
    @"C:\Users\User\Desktop\input.csv",
    @"C:\Users\User\Desktop\output.docx"
);

CSV to YAML Conversion

await fileConverter.ConvertCsvToYamlAsync(
    @"C:\Users\User\Desktop\input.csv",
    @"C:\Users\User\Desktop\output.yaml"
);

CSV to JSON Conversion

await fileConverter.ConvertCsvToJsonAsync(
    @"C:\Users\User\Desktop\input.csv",
    @"C:\Users\User\Desktop\output.json"

XML to CSV Conversion

await fileConverter.ConvertXmlToCsvAsync(
    @"C:\Users\User\Desktop\input.xml",
    @"C:\Users\User\Desktop\output.csv"
);

XML to PDF Conversion

await fileConverter.ConvertXmlToPdfAsync(
    @"C:\Users\User\Desktop\input.xml",
    @"C:\Users\User\Desktop\output.pdf"
);

XML to Word Conversion

await fileConverter.ConvertXmlToWordAsync(
    @"C:\Users\User\Desktop\input.xml",
    @"C:\Users\User\Desktop\output.docx"
);

XML to YAML Conversion

await fileConverter.ConvertXmlToYamlAsync(
    @"C:\Users\User\Desktop\input.xml",
    @"C:\Users\User\Desktop\output.yaml"
);

XML to JSON Conversion

await fileConverter.ConvertXmlToJsonAsync(
    @"C:\Users\User\Desktop\input.xml",
    @"C:\Users\User\Desktop\output.json"
);

Notes

Notes The CsvToXmlConverter, CsvToJsonConverter, CsvToPdfConverter, CsvToWordConverter, and CsvToYamlConverter classes read a CSV file, parse it, and write the content to an XML, JSON, PDF, Word, and YAML file respectively. The first line of the CSV file is assumed to be the header.

The XmlToCsvConverter, XmlToJsonConverter, XmlToPdfConverter, XmlToWordConverter, and XmlToYamlConverter classes read an XML file, parse it, and write the content to a CSV, JSON, PDF, Word, and YAML file respectively. The XML file is assumed to be in the format produced by the CsvToXmlConverter.

All classes handle errors such as file not found and invalid file format, and print an error message to the console.

Contributing

Contributions are welcome. Please fork the repository and create a pull request with your changes.

Author

Bohdan Harabadzhyu

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
1.3.0 161 4/9/2025
1.2.0 98 11/27/2024
1.1.0 117 6/8/2024
1.0.0 276 11/18/2023

Version 1.3.0:
           - (Released: 8 April 2025) - Major architecture refactoring to use generic IConverter.
           - Combined FileConverterFacade and ServiceLocator into a unified FileConverter class.
           - Fixed CsvToJsonConverter to properly format output as array of objects with type conversion.
           - Improved XmlToYamlConverter to correctly preserve hierarchical structure.
           - Fixed type conversion issues in XmlToWordConverter.
           - Enhanced hierarchical formatting in YAML and Word conversions.
           - Rewrote unit tests to match the new architecture.
           - Added better support for type conversion across all converters.
           - Improved error handling and validation.