FileConversionLibrary 1.2.0
dotnet add package FileConversionLibrary --version 1.2.0
NuGet\Install-Package FileConversionLibrary -Version 1.2.0
<PackageReference Include="FileConversionLibrary" Version="1.2.0" />
paket add FileConversionLibrary --version 1.2.0
#r "nuget: FileConversionLibrary, 1.2.0"
// Install FileConversionLibrary as a Cake Addin #addin nuget:?package=FileConversionLibrary&version=1.2.0 // Install FileConversionLibrary as a Cake Tool #tool nuget:?package=FileConversionLibrary&version=1.2.0
File Conversion Library
This library provides functionality to convert CSV and XML files to various formats such as XML, PDF, Word, JSON, and YAML.
Usage
CSV to XML Conversion
var converter = new CsvToXmlConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.csv", @"C:\Users\User\Desktop\output.xml");
CSV to PDF Conversion
var converter = new CsvToPdfConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.csv", @"C:\Users\User\Desktop\output.pdf");
CSV to Word Conversion
var converter = new CsvToWordConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.csv", @"C:\Users\User\Desktop\output.docx");
CSV to YAML Conversion
var converter = new CsvToYamlConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.csv", @"C:\Users\User\Desktop\output.yaml");
CSV to JSON Conversion
var converter = new CsvToJsonConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.csv", @"C:\Users\User\Desktop\output.json");
XML to CSV Conversion
var converter = new XmlToCsvConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.xml", @"C:\Users\User\Desktop\output.csv");
XML to PDF Conversion
var converter = new XmlToPdfConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.xml", @"C:\Users\User\Desktop\output.pdf");
XML to Word Conversion
var converter = new XmlToWordConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.xml", @"C:\Users\User\Desktop\output.docx");
XML to YAML Conversion
var converter = new XmlToYamlConverter();
await converter.ConvertAsync(@"C:\Users\User\Desktop\input.xml", @"C:\Users\User\Desktop\output.yaml");
XML to JSON Conversion
var converter = new XmlToJsonConverter();
await converter.ConvertAsync(@"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
Product | Versions 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. |
-
net8.0
- CsvHelper (>= 33.0.1)
- DocumentFormat.OpenXml (>= 3.0.2)
- iTextSharp (>= 5.5.13.3)
- Newtonsoft.Json (>= 13.0.3)
- YamlDotNet (>= 15.1.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.2.0:
- (Released: 27 November 2024) - Added async support for all converters.
- Implemented CsvHelperFile for reading CSV files.
- Implemented XmlHelperFile for reading XML files.
- Added unit tests for all converters.
- Improved error handling and logging..