|
|
置顶随笔
前两天一个long long ago的客户的助理MM通过MSN联系到我,楚楚可怜(用了很多MSN表情)的说有个很紧急的事,让我帮她个忙。原来他们公司年终盘点,有8k多种产品,每种产品要生成一个盘点单(excel sheet)。产品列表也在一个叫goods.xsl的excel表中。这位助理MM会点宏,可惜功底太弱,做不来。 我本就乐于助人,现又不禁怜香惜玉起来,正要满口答应的时候,mm又说:"老大说了,这会给报酬的哦!",我喜出望外,然后商定完成后给我500大圆。ok,我在网上Ctrl+c,Ctrl +v了一通,做成了下面这个值500大圆的代码。
class Program { static void Main(string[] args) { PrintFilledCard(); }
private static void PrintFilledCard() {
Console.Write("开始号:"); string stmp = Console.ReadLine(); int start = int.Parse(stmp); Console.Write("结束号:"); stmp = Console.ReadLine(); int end = int.Parse(stmp);
Console.WriteLine("Waitting...");
string cardFileName = @"D:\Code\ExcelAuto\Cards.xls"; string goodsFileName = @"D:\Code\ExcelAuto\Goods.xls"; string saveFileName = @"D:\Code\ExcelAuto\Cards1.xls";
object missing = System.Reflection.Missing.Value; Excel.Application ThisApplication = new ApplicationClass();
Workbook workBookTemplate = null; Workbook workBookGoods = null;
try { //加载产品文件 workBookGoods = ThisApplication.Workbooks.Open(goodsFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Worksheet sheetGoods = (Worksheet)workBookGoods.Sheets[1];
//加载Excel模板文件 workBookTemplate = ThisApplication.Workbooks.Open(cardFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Worksheet sheetTemplate = (Worksheet)workBookTemplate.Sheets[1]; ThisApplication.Visible = false;
int index = start + 1; int errorCount = 0; int totalCount = sheetGoods.UsedRange.Rows.Count - 1; // int totalCount = (int)numericTotal.Value; end = end + 1;
object goodsSN = null; object goodsID = null; object goodsName = null; object goodsDepository = null; object goodsUnit = null; string pageFooter; DateTime startTime = DateTime.Now;
while (index <= end && errorCount < 3) { sheetTemplate.Copy(missing, workBookTemplate.Sheets[workBookTemplate.Sheets.Count]); Worksheet sheetNew = (Worksheet)workBookTemplate.Sheets[workBookTemplate.Sheets.Count]; sheetNew.Name = (index - 1).ToString();
try { goodsSN = sheetGoods.Cells[index, 1]; goodsID = sheetGoods.Cells[index, 2]; goodsName = sheetGoods.Cells[index, 3]; goodsUnit = sheetGoods.Cells[index, 4]; goodsDepository = sheetGoods.Cells[index, 5];
sheetNew.Cells[4, 2] = goodsSN; sheetNew.Cells[5, 2] = goodsID; sheetNew.Cells[6, 2] = goodsName; sheetNew.Cells[7, 2] = goodsUnit; sheetNew.Cells[7, 4] = goodsDepository;
pageFooter = string.Format("第{0}页/共{1}页", index - 1, totalCount); //sheetNew.Cells[12, 4] = pageFooter; Console.WriteLine(pageFooter);
} catch { errorCount++; } index++;
if (index > end) { break; }
//一页两个 try { goodsSN = sheetGoods.Cells[index, 1]; goodsID = sheetGoods.Cells[index, 2]; goodsName = sheetGoods.Cells[index, 3]; goodsUnit = sheetGoods.Cells[index, 4]; goodsDepository = sheetGoods.Cells[index, 5];
sheetNew.Cells[19, 2] = goodsSN; sheetNew.Cells[20, 2] = goodsID; sheetNew.Cells[21, 2] = goodsName; sheetNew.Cells[22, 2] = goodsUnit; sheetNew.Cells[22, 4] = goodsDepository;
pageFooter = string.Format("第{0}页/共{1}页", index - 1, totalCount); //sheetNew.Cells[12, 4] = pageFooter; Console.WriteLine(pageFooter); } catch { errorCount++; } index++;
}
//删除模版页 sheetTemplate.Delete();
//更新数据后另存为新文件 workBookTemplate.SaveAs(saveFileName, missing, missing, missing, missing, missing, XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
Console.WriteLine("All done."); DateTime endTime = DateTime.Now; Console.Write("{0}~{1},total time: {2}", startTime, endTime, endTime - startTime); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { workBookTemplate.Close(false, missing, missing); workBookTemplate = null;
ThisApplication.Quit();
ThisApplication = null;
} try { ////打开刚才生成的Excel文件 //Microsoft.Office.Interop.Excel.Application NewApplication = new Microsoft.Office.Interop.Excel.ApplicationClass(); //Microsoft.Office.Interop.Excel.Workbook NewWorkBook;
//NewWorkBook = NewApplication.Workbooks.Open(strSaveFileName, missing, missing, missing, missing, missing, missing, missing, // missing, missing, missing, missing, missing, missing, missing); //Microsoft.Office.Interop.Excel.Worksheet NewSheet = (Microsoft.Office.Interop.Excel.Worksheet)NewWorkBook.Sheets[1]; //NewApplication.Visible = true;
System.Diagnostics.Process.Start(saveFileName);//来打开新文件
} catch (Exception ex) { Console.WriteLine(ex.Message); }
Console.Read(); } }
-------- --- 开源的BUG管理系统,易于安装,使用方便! http://sourceforge.net/projects/bugonline 基于Asp.net2.0,Ajax ,sqlserver2005,欢迎加入共同维护.
开源版本的bug管理系统 BugOnline大本营已搬至: http://sourceforge.net/projects/bugonline基于Asp.net2.0,Ajax ,sqlserver2005, 易于安装使用,欢迎加入共同维护.
2006年12月28日
前两天一个long long ago的客户的助理MM通过MSN联系到我,楚楚可怜(用了很多MSN表情)的说有个很紧急的事,让我帮她个忙。原来他们公司年终盘点,有8k多种产品,每种产品要生成一个盘点单(excel sheet)。产品列表也在一个叫goods.xsl的excel表中。这位助理MM会点宏,可惜功底太弱,做不来。 我本就乐于助人,现又不禁怜香惜玉起来,正要满口答应的时候,mm又说:"老大说了,这会给报酬的哦!",我喜出望外,然后商定完成后给我500大圆。ok,我在网上Ctrl+c,Ctrl +v了一通,做成了下面这个值500大圆的代码。
class Program { static void Main(string[] args) { PrintFilledCard(); }
private static void PrintFilledCard() {
Console.Write("开始号:"); string stmp = Console.ReadLine(); int start = int.Parse(stmp); Console.Write("结束号:"); stmp = Console.ReadLine(); int end = int.Parse(stmp);
Console.WriteLine("Waitting...");
string cardFileName = @"D:\Code\ExcelAuto\Cards.xls"; string goodsFileName = @"D:\Code\ExcelAuto\Goods.xls"; string saveFileName = @"D:\Code\ExcelAuto\Cards1.xls";
object missing = System.Reflection.Missing.Value; Excel.Application ThisApplication = new ApplicationClass();
Workbook workBookTemplate = null; Workbook workBookGoods = null;
try { //加载产品文件 workBookGoods = ThisApplication.Workbooks.Open(goodsFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Worksheet sheetGoods = (Worksheet)workBookGoods.Sheets[1];
//加载Excel模板文件 workBookTemplate = ThisApplication.Workbooks.Open(cardFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); Worksheet sheetTemplate = (Worksheet)workBookTemplate.Sheets[1]; ThisApplication.Visible = false;
int index = start + 1; int errorCount = 0; int totalCount = sheetGoods.UsedRange.Rows.Count - 1; // int totalCount = (int)numericTotal.Value; end = end + 1;
object goodsSN = null; object goodsID = null; object goodsName = null; object goodsDepository = null; object goodsUnit = null; string pageFooter; DateTime startTime = DateTime.Now;
while (index <= end && errorCount < 3) { sheetTemplate.Copy(missing, workBookTemplate.Sheets[workBookTemplate.Sheets.Count]); Worksheet sheetNew = (Worksheet)workBookTemplate.Sheets[workBookTemplate.Sheets.Count]; sheetNew.Name = (index - 1).ToString();
try { goodsSN = sheetGoods.Cells[index, 1]; goodsID = sheetGoods.Cells[index, 2]; goodsName = sheetGoods.Cells[index, 3]; goodsUnit = sheetGoods.Cells[index, 4]; goodsDepository = sheetGoods.Cells[index, 5];
sheetNew.Cells[4, 2] = goodsSN; sheetNew.Cells[5, 2] = goodsID; sheetNew.Cells[6, 2] = goodsName; sheetNew.Cells[7, 2] = goodsUnit; sheetNew.Cells[7, 4] = goodsDepository;
pageFooter = string.Format("第{0}页/共{1}页", index - 1, totalCount); //sheetNew.Cells[12, 4] = pageFooter; Console.WriteLine(pageFooter);
} catch { errorCount++; } index++;
if (index > end) { break; }
//一页两个 try { goodsSN = sheetGoods.Cells[index, 1]; goodsID = sheetGoods.Cells[index, 2]; goodsName = sheetGoods.Cells[index, 3]; goodsUnit = sheetGoods.Cells[index, 4]; goodsDepository = sheetGoods.Cells[index, 5];
sheetNew.Cells[19, 2] = goodsSN; sheetNew.Cells[20, 2] = goodsID; sheetNew.Cells[21, 2] = goodsName; sheetNew.Cells[22, 2] = goodsUnit; sheetNew.Cells[22, 4] = goodsDepository;
pageFooter = string.Format("第{0}页/共{1}页", index - 1, totalCount); //sheetNew.Cells[12, 4] = pageFooter; Console.WriteLine(pageFooter); } catch { errorCount++; } index++;
}
//删除模版页 sheetTemplate.Delete();
//更新数据后另存为新文件 workBookTemplate.SaveAs(saveFileName, missing, missing, missing, missing, missing, XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);
Console.WriteLine("All done."); DateTime endTime = DateTime.Now; Console.Write("{0}~{1},total time: {2}", startTime, endTime, endTime - startTime); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { workBookTemplate.Close(false, missing, missing); workBookTemplate = null;
ThisApplication.Quit();
ThisApplication = null;
} try { ////打开刚才生成的Excel文件 //Microsoft.Office.Interop.Excel.Application NewApplication = new Microsoft.Office.Interop.Excel.ApplicationClass(); //Microsoft.Office.Interop.Excel.Workbook NewWorkBook;
//NewWorkBook = NewApplication.Workbooks.Open(strSaveFileName, missing, missing, missing, missing, missing, missing, missing, // missing, missing, missing, missing, missing, missing, missing); //Microsoft.Office.Interop.Excel.Worksheet NewSheet = (Microsoft.Office.Interop.Excel.Worksheet)NewWorkBook.Sheets[1]; //NewApplication.Visible = true;
System.Diagnostics.Process.Start(saveFileName);//来打开新文件
} catch (Exception ex) { Console.WriteLine(ex.Message); }
Console.Read(); } }
-------- --- 开源的BUG管理系统,易于安装,使用方便! http://sourceforge.net/projects/bugonline 基于Asp.net2.0,Ajax ,sqlserver2005,欢迎加入共同维护.
2006年12月14日
开源版本的bug管理系统 BugOnline大本营已搬至: http://sourceforge.net/projects/bugonline基于Asp.net2.0,Ajax ,sqlserver2005, 易于安装使用,欢迎加入共同维护.
2006年6月4日
许多软件都需要得到用户的体验及BUG反馈,甚至创意!以便更好的改进BUG.用EMAIL来收集吗?有点原始了。这里介绍一个更好的方法,她能方便收集用户反馈,又能方便的管理反馈。
借助http://BugOnline.net,只需几个步骤,就能让自己的软件拥有在线的BUG反馈功能。 1.到http://BugOnline.net申请免费的bug管理服务. 2.并登记您的公司,项目(只需几分钟),假设您的项目名叫:p1 . 3.您就可以通过链接 http://bugonline.net/BMS/AddBug1.aspx?P=p1 ;您只要把参数p1改为您自己的项目名就可以了,粘贴到浏览器试试看,出来了吗?
4.好了,您已经有了一个在线的BUG反馈系统了。然后您可以把它集成到自己的软件中了,如在菜单中加一项叫 "用户反馈",让用户一点击就打开此链接,方便用户报告BUG,需求等等。
5. 备注: 在"项目详情"-->"项目高级设定" 中,将 "非项目成员可添加BUG" 设为 "是" 。让普通用户也能给此项目反馈BUG,否则只适合项目成员内部使用。
以后您就可以通过BugOnline.net来收集管理您的bug了。
Linda.Wang
2006年4月20日
业界第一个开放式在线bug管理系统 http://bugonline.net 满月了! 更值得庆贺的是,已经有用户在正式使用这个管理系统了!需要的朋友可以去免费注册。
小孩子成长的很快,相比一个月前已有了很大变化,功能更强大,操作也更方便了。
虽然没做多少推广工作,但却持续不断的有很多朋友去试用,说明我们这个系统是蛮受欢迎的。其间虽未出现啥大问题但却被网友发现了些BUG,虽然小但我们还是觉得很愧疚,毕竟我们是做BUG管理系统的。 还有很多网友提了很多不错的建议,对我们帮助很大,真的很感谢这些朋友。 但所谓众口难调,孩子还小,现在无法百分百满足客户的需求,但我们会不断努力,把bugonline做的更好! 谢谢!
2006年3月20日
这是一个后台发mail的类 ,用在 http://BugOnline.org 网站上,在系统中使用的很好,特拿出来共享。 用的是.net framework 2.0.
其中用到了.net2.0最新的System.Net.Mail空间,比.net 1.1好用多了。 还有线程类。有兴趣的朋友可以看看。
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text; using System.Net.Mail; using System.Net;
using System.Threading;
namespace com.XXX.SPMS.Common { /// <summary> /// Mail 多进程发mail /// </summary> public class Mail { private string subject; private string body; private string[] mailTo;
/// <summary> /// Mail /// </summary> /// <param name="mailTo"></param> /// <param name="subject"></param> /// <param name="body"></param> public Mail(string[] mailTo, string subject, string body) { this.mailTo = mailTo; this.subject = subject; this.body = body; }
/// <summary> /// Send a mail no MultiThread /// </summary> /// <returns></returns> public void Send() { Send(mailTo, subject, body); }
/// <summary> /// Send a mail MultiThread /// </summary> /// <param name="mailTo"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <returns></returns> public static void SendAtBackground(string[] mailTo, string subject, string body) { Mail newMail = new Mail(mailTo, subject, body); Thread thread = new Thread(new ThreadStart(newMail.Send)); thread.Start(); }
/// <summary> /// Send /// </summary> /// <returns></returns> private static bool Send(string[] mailTo, string subject, string body) { MailMessage msg = new MailMessage(); try { msg.From = new MailAddress(SPMSConfiguration.MailSender);
foreach (string address in mailTo) { msg.To.Add(address); }
msg.Subject = subject; msg.Body = body;
System.Net.Mail.SmtpClient smtp = new SmtpClient(SPMSConfiguration.SmtpServer); smtp.Credentials = new NetworkCredential(SPMSConfiguration.SmtpCredential, SPMSConfiguration.CredentialPassword);
smtp.Send(msg); } catch (Exception) { } return true; } } }
------ http://BugOnline.org 在线的Bug管理网站 http://spaces.msn.com/fanciex/
2006年3月19日
这是一个C#+asp.net 开发的Bug跟踪管理系统。可以在线使用,十分方便。
传统的Bug跟踪管理系统都是 一套软件。让用户下载 安装,配置,十分繁琐费时。
两年前公司的开发主管需要一套bug管理软件,打算用BugZilla,结果下面的测试组搞了n天没搞定,找到我帮忙,结果我也又搞了n天多才配好,源代码修改了一大堆,狂晕。
配置好以后,公司开发人员还对这个系统抱怨一大堆。又是英文的,然后外地的开发人员,和在客户那边的开发人员都不能用,还是要自己记录Bug,回来后才录入系统
看到这种情况,我决定开发一套自己的Bug管理系统,叫spms [software process management system] 软件过程管理系统. 就是 http://BugOnline.net 的前身。在公司推广, 结果大受同事欢迎,客户直接就可以把Bug需求等 ,提交到这个系统中。客服人员也轻松多了。
后来想 应该很多公司都存在这些问题。为何不把这个系统推广出去让大家都能使用呢?
于是重新开发,让其能管理多公司多项目 ,就有了今天的 http://BugOnline.net 如果您也需要这样的Bug管理系统,不妨去免费注册使用。
|