You can use the GoodGrids API in .NET in C# without any external dependencies. Just use this snippet to send the CSV file to the GoodGrids API and get back a response with the Excel spreadsheet.
HttpWebRequest request = WebRequest.Create( "https://api.goodgrids.com/api/convert/v1/csv-to-excel/3a6c0d9ac7c74d" ) as HttpWebRequest;
// Set type to POST
request.Method = "POST";
request.ContentType = "text/csv;";
// Create a byte array of the csv_data we want to send
byte[] byteData = Encoding.UTF8.GetBytes( csv_data.ToString() );
// Set the content length in the request headers
request.ContentLength = byteData.Length;
// Write data
using ( Stream postStream = request.GetRequestStream() )
{
postStream.Write( byteData, 0, byteData.Length );
}
// Get response
using ( HttpWebResponse response = request.GetResponse() as HttpWebResponse )
{
Stream responseStreamContainingExcelFileData = response.GetResponseStream();
}
Make sure to set the API URL of the CSV-to-Excel conversion configuration you want to use.
This snippet of code uses the Apache HttpClient 4 for the API request. You can adapt this code to use whichever client library you want.
Found a bug? Have a suggestion on how to improve this documentation? Please send us a note at support@goodgrids.com.