Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet oSheet;
Excel.Range oRng;
//Start Excel and get Application object.
oXL = new Excel.Application();
oXL.Visible = true;
//Get a new workbook.
oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
//Add table headers going cell by cell.
oSheet.Cells[1, 1] = "Verifikat";
oSheet.Cells[1, 2] = "Datum";
oSheet.Cells[1, 3] = "Beskrivning";
oSheet.Cells[1, 4] = "Konto";
oSheet.Cells[1, 5] = "Debit";
oSheet.Cells[1, 6] = "Kredit";
//Format A1:D1 as bold, vertical alignment = center.
oSheet.get_Range("A1", "F1").Font.Bold = true;
oSheet.get_Range("A1", "F1").VerticalAlignment =
Excel.XlVAlign.xlVAlignCenter;
var VouchersConnector = new VoucherConnector();
VouchersConnector.ClientSecret = "abc123";
VouchersConnector.AccessToken = "abc123";
for (int iloop = 1; iloop < 61; ++iloop)
{
VouchersConnector.Limit = 500;
VouchersConnector.Page = iloop;
VouchersConnector.FinancialYearID = "1";
var verifikat = VouchersConnector.Find();
int rownumber = 2;
foreach (var item in verifikat.VoucherSubset)
{
var voucherNumber = item.VoucherNumber;
var voucherSeries = item.VoucherSeries;
var test = VouchersConnector.Get("A", voucherNumber);
var vatCode = test.VoucherSeries;
var desc = test.Description;
var rows = test.VoucherRows;
var vdate = test.TransactionDate;
foreach(var VoucherRow in rows)
{
var deb = VoucherRow.Debit;
var cred = VoucherRow.Credit;
var acc = VoucherRow.Account;
var varRowsCount = rows.Count;
oSheet.Cells[rownumber, 1] = voucherSeries + voucherNumber;
oSheet.Cells[rownumber, 2] = vdate;
oSheet.Cells[rownumber, 3] = desc;
oSheet.Cells[rownumber, 4] = acc;
oSheet.Cells[rownumber, 5] = deb;
oSheet.Cells[rownumber, 6] = cred;
rownumber = rownumber + 1;
}
Thread.Sleep(250);
}
}
}
}