Posted on 25/10/2019 12:48:15
That is hardcoded I am affraid.
Here is the code - you can easily convert it to C# and add it to the razor template file and customize it:
Public Shared Sub RenderExcel(ByVal shopId As String, orderContextId As String)
Dim response = Context.Current.Response
Dim uid As Integer = (Security.UserManagement.User.GetCurrentExtranetUser()?.ID).GetValueOrDefault
Dim isQuote As Boolean = Converter.ToString(Context.Current.Request("OrderType")) = "quotes"
Dim isLedgerEntry As Boolean = String.Equals(Context.Current.Request("OrderType"), "LedgerEntries", StringComparison.CurrentCultureIgnoreCase)
If uid = 0 Then response.End()
With response
.Clear()
.ContentType = "application/vnd.ms-excel; charset=" & Text.Encoding.UTF32.WebName
End With
response.AddHeader("content-disposition", "attachment;filename=MyOrders.xls")
Dim orderType As OrderType = OrderType.Order
If isQuote Then
orderType = OrderType.Quote
ElseIf isLedgerEntry Then
orderType = OrderType.LedgerEntry
End If
Dim customerOrders = New CustomerOrderCollection()
customerOrders.Load(uid, shopId, orderType, 0, False, orderContextId)
customerOrders.Sort("OrderID", SortOrderType.Asc)
Dim sb As New Text.StringBuilder()
'// Write headers
With sb
.Append("Date" + vbTab)
.Append("Order ID" + vbTab)
.Append("Product ID" + vbTab)
.Append("Product Number" + vbTab)
.Append("Variant ID" + vbTab)
.Append("Variant Text" + vbTab)
.Append("Product Name" + vbTab)
.Append("Quantity" + vbTab)
.Append("Unit Price" + vbTab)
.Append("Currency" + vbTab)
.Append("Currency Rate" + vbTab)
.Append(vbCrLf)
End With
For Each enumOrder As Order In customerOrders
For Each orderLine As OrderLine In enumOrder.OrderLines
With sb
.Append(enumOrder.Date.ToShortDateString() + vbTab)
.Append(enumOrder.Id + vbTab)
.Append(orderLine.ProductId + vbTab)
.Append(orderLine.ProductNumber + vbTab)
.Append(orderLine.ProductVariantId + vbTab)
.Append(orderLine.ProductVariantText + vbTab)
.Append(orderLine.ProductName + vbTab)
.Append(orderLine.Quantity.ToString() + vbTab)
.Append(orderLine.Price.Price.ToString() + vbTab)
.Append(enumOrder.CurrencyCode + vbTab)
.Append(enumOrder.CurrencyRate.ToString() + vbTab)
.Append(vbCrLf)
End With
Next
Next
response.BinaryWrite(Text.Encoding.UTF32.GetPreamble())
response.BinaryWrite(Text.Encoding.UTF32.GetBytes(sb.ToString()))
response.Flush()
response.End()
End Sub