1. C# / Говнокод #8389

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    public void ExportOrderDetails()
            {
                char comma = ',';
                StringBuilder sb = new StringBuilder();
                string line = "";
    
                line += "Order No" + comma;
                line += "Customer" + comma;
                line += "Order Date" + comma;
                line += "Order Status" + comma;
                line += "Subtotal" + comma;
                line += "Tax Total" + comma;
                line += "Shipping Cost" + comma;
                line += "Shipping Method" + comma;
                line += "Order Total" + comma;
                line += "Payment Method" + comma;
                line += "Total Quantity" + comma;
                line += "Date Shipped" + comma;
                line += "Tracking No" + comma;
                line += "Order Currency Code" + comma;
                line += "Exchange Rate" + comma;
                line += "Billing First Name" + comma;
                line += "Billing Last Name" + comma;
                line += "Billing Company" + comma;
                line += "Billing Address" + comma;
                line += "Billing Address 2" + comma;
                line += "Billing City" + comma;
                line += "Billing Zip" + comma;
                line += "Billing State Code" + comma;
                line += "Billing Country ISO2" + comma;
                line += "Billing Phone" + comma;
                line += "Billing Phone 2" + comma;
                line += "Billing Email" + comma;
                line += "Shipping First Name" + comma;
                line += "Shipping Last Name" + comma;
                line += "Shipping Company" + comma;
                line += "Shipping Address" + comma;
                line += "Shipping Address 2" + comma;
                line += "Shipping City" + comma;
                line += "Shipping Zip" + comma;
                line += "Shipping State Code" + comma;
                line += "Shipping Country ISO2" + comma;
                line += "Shipping Phone" + comma;
                line += "Shipping Phone 2" + comma;
                line += "Shipping Email" + comma;
    
                line += "Combined Product Weight" + comma;
                line += "Product Qty" + comma;
                line += "Product SKU" + comma;
                line += "Product Name" + comma;
                line += "Product Variation Details" + comma;
                line += "Product Unit Price" + comma;
                line += "Product Unit Cost" + comma;
                line += "Product Weight" + comma;
                line += "Product Total Price" + comma;
                line += "Product Total Cost" + comma;
    
    
    
                sb.AppendLine(line.Remove(line.Length - 1));
     
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", "attachment; filename=orders-details-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv");
                Response.ContentEncoding = Encoding.Default;
                Response.Write(sb.ToString());
                Response.End();
    
            }

    Норм так)

    Запостил: sergfreest, 01 Ноября 2011

    Комментарии (5) RSS

    • главное что использовал StringBuilder
      Ответить
    • какая разница, все одно в StringBuilder развернется
      Ответить
    • Это шедевр! Так надо умудрится. Забукмарчука я эту страничку
      Ответить
    • - Что, правда в глаза колет? Я хоть не скрываю от всех, - с ещё большим ехидством заметила Инга.
      Ответить

    Добавить комментарий