批量发工资或发邮件

来源:互联网 发布:net高级编程 编辑:程序博客网 时间:2024/05/01 19:06

本程序用的C#语言开发,用的是.net farmework3.5库。主要给公司HR实现批量发工资条和拆分工资条

程序界面如下:

本程序需要引用外部的程序集 

Microsoft.Exchange.WebServices.dll   发送Exchange类型邮件 需要从微软官网下载

EPPlus.dl   用于操作Excel文件(当然用NPOI,或者OPENXML SDK都可以)

Ckeditor 插件,主要用于编辑签名信息的,主要支持内容嵌入图片。

 

在用Exchange发送邮件,在发送内容嵌入图片核心代码如下

string file = @"C:\Users\contoso\Pictures\Party.jpg";

email.Attachments.AddFileAttachment("Party.jpg", file);

email.Attachments[0].IsInline = true;

email.Attachments(0).ContentId = "Party.jpg"

参考如下面网站

http://msdn.microsoft.com/en-us/library/hh532564(v=exchg.80).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 

 

/// Excel数字转成Excel行头算法, 如根据像1-〉A 2-〉B, 27-〉AA等

        private string GetColumnName(int column)

        {

            int value = 0;

            int remainder = 0;

            string result = string.Empty;

            value = column;

            while (value > 0)

            {

                remainder = (value - 1) % 26;

                result = (char)(65 + remainder) + result;

                value = (int)(Math.Floor((double)((value - remainder) / 26)));

            }

            return result;

        }

写此程序参考的网站

http://www.cnblogs.com/scwyh/p/3483365.html  EPPlus操作数据导入导出

http://www.cnblogs.com/rumeng/p/3785748.html  EPPlus操作

http://blog.csdn.net/agai001/article/details/38925927   C# 通过Exchange 服务器发送

http://blog.csdn.net/windflow/article/details/7741903  SMTP发送邮件方式

http://www.codeproject.com/  绝对是个好网站,里面资源很好,epplus,exchange都在里面找到参考代码。

http://ckeditor.com/demo  ckeditor官网

http://holyrain1314.blog.163.com/blog/static/100114135201092111041689/ ckeditor的使用方法,如果英文好可以去官网看文档

http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData  ckedito使用介绍

 

在写此程序遇到没解决的问题, 在使用EPPluse拆分文件,需要复制一行数据时,复制采用的是worksheet.Cells[rowIndex,cellIndex].copy方法,发现复制行发现格式会出现问题, 无柰之下, 利用 模板方法的方法实现了,相当读取模板中的内容,往里面填充数据, 而且只实现复制了文字和批注功能,  还是要用户手动定义模板!

 

这主要用于显示签名信息的,因为公司HR签名需要带图片的,用了ckeditor控件去实现显示和编辑, 因为没找到好的html显示的编辑器, 局限性还是比较大的,有什么好的方法记得介绍给我呀,谢谢!

0 0
原创粉丝点击