I am generating invoices from within my LightSwitch billing application, and after an invoice is generated, the SubTotal, SalesTax and Total Due cells in the Word document are not of the correct format.
I have gone through every single menu option, and explored other possible ways to have it formatted before it gets put in the document's Content control, but I just can't get the right format.
The numbers are being displayed as 4100.0000
, but they should be like 4,100.00
or at least like 4100.00
.
How can this be done?
I realise that this is borderline off-topic, but I figured I'd post here anyway as I believe the solution involves writing code, as opposed to using Word to accomplish this, because I have gone through all the options, and there just doesn't seem to be an option in there to change formatting for a single cell.
As requested, code for document generation:
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using OfficeIntegration;
namespace LightSwitchApplication
{
public partial class Billing
{
partial void GenerateInvoice_Execute()
{
var mappings = new List<ColumnMapping>();
mappings.Add(new ColumnMapping("InvoiceId", "InvoiceId"));
mappings.Add(new ColumnMapping("DateGenerated", "DateGenerated"));
mappings.Add(new ColumnMapping("InvoiceDataGridSubTotal", "SubTotal"));
mappings.Add(new ColumnMapping("InvoiceDataGridSalesTax", "Tax"));
mappings.Add(new ColumnMapping("InvoiceDataGridDateDue", "DateDue"));
mappings.Add(new ColumnMapping("InvoiceDataGridTotalDue", "Total"));
object doc;
string path = @"C:\Users\Jason\Documents\SV Invoice.docx";
doc = OfficeIntegration.Word.GenerateDocument(path, this.BillingTables.SelectedItem, mappings);
}
}
}