Skip to content

Instantly share code, notes, and snippets.

Last active Mar 29, 2016
What would you like to do?
private static void ImportTransactionsFromFile(PX.SM.FileInfo file)
ImportTest graph = new ImportTest();
Byte[] bytes = file.BinData;
using(PX.Data.XLSXReader reader = new XLSXReader(bytes))
//Initialising Reader
//Creating a dictionary to find column index by name
Dictionary<String, Int32> indexes = reader.IndexKeyPairs.ToDictionary(p => p.Value, p => p.Key);
//Skipping first row with collumns names.
Tran row = graph.Transactions.Insert();
//Transforming External representation to Internal by using SetValueExt method.
graph.Transactions.Cache.SetValueExt(row, "AccountID", reader.GetValue(indexes["Account"]));
graph.Transactions.Cache.SetValueExt(row, "SubID", reader.GetValue(indexes["Account"]));
//Converting to Decimal
row.Qty = Decimal.Parse(reader.GetValue(indexes["Quantity"]));
row.DebitAmt = Decimal.Parse(reader.GetValue(indexes["Debit Amount"]));
row.CreditAmt = Decimal.Parse(reader.GetValue(indexes["Credit Amount"]));
row = graph.Transactions.Update(row);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment