列表框到 Excel
好的,所以我有一个类,客户,我用它来处理数据,然后添加到列表框,如下所示:
//Submit data from current form
customer aCustomer = new customer(comboBox1.Text, textBox1.Text, ChannelSelecBox.Text,
PurchaserTextBox.Text, NameTextBox.Text, emailTextBox.Text, AddressTextBox.Text, StateBox.Text,
PayMethodDropDown.Text, Prod1Num.Value.ToString(), Prod2Num.Value.ToString(),
Prod3Num.Value.ToString(), Prod4Num.Value.ToString(), Prod5Num.Value.ToString(),
Prod6Num.Value.ToString(), SubTData.Text, DiscountTextBox.Text, TaxData.Text, CommentTextBox.Text,
ShipData.Text, TotalData.Text);
// Add aCustomer to ListBox
Orders.Items.Add(aCustomer);
我有一个字符串覆盖,以便列表框只显示购买者和日期。 现在,我想获取输入列表框中的所有订单,并将大部分数据放入 Excel 电子表格中,每个订单放入其自己的列中。我怎么能这样做呢?
如果您需要更多信息或查看更多我的代码,请告诉我。
Ok, so I have a class, customer, that I use to process data, and then add to a list box, like below:
//Submit data from current form
customer aCustomer = new customer(comboBox1.Text, textBox1.Text, ChannelSelecBox.Text,
PurchaserTextBox.Text, NameTextBox.Text, emailTextBox.Text, AddressTextBox.Text, StateBox.Text,
PayMethodDropDown.Text, Prod1Num.Value.ToString(), Prod2Num.Value.ToString(),
Prod3Num.Value.ToString(), Prod4Num.Value.ToString(), Prod5Num.Value.ToString(),
Prod6Num.Value.ToString(), SubTData.Text, DiscountTextBox.Text, TaxData.Text, CommentTextBox.Text,
ShipData.Text, TotalData.Text);
// Add aCustomer to ListBox
Orders.Items.Add(aCustomer);
I have a string override so that the listbox just displays the purchaser and the date.
Now I want to take all the orders entered into the list box and put, most of, this data into an excel spreadsheet, each into it's own column. How could I do this?
If you need more information or to see more of my code, let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下方法;
更多详细信息,请访问 http://csharp.net-informations.com /excel/csharp-create-excel.htm
try the following;
more details can be found at http://csharp.net-informations.com/excel/csharp-create-excel.htm
使用 CSV 作为文件格式,而不是 XLS。 Excel 是一种痛苦。尤其是在读取 XLS 时。有些单元格格式不正确,您有时会得到该值,但有时却得不到。即使在同一个文件中。个人经历。
Use CSV as file format, not XLS. Excel is a pain. Especially when reading from XLS. Some incorrect cell formatting and you sometimes get the value, but sometimes not. Even in same file. Personal experience.