public void Generate()
{
string DirPath = "";
{
HttpContext HttpCurrent = HttpContext.Current;
if (HttpCurrent != null)
DirPath = HttpCurrent.Server.MapPath("~");
else
DirPath = AppDomain.CurrentDomain.BaseDirectory;
if (DirPath[DirPath.Length - 1] != '\\')
DirPath += @"\";
}
Application mApp = new Application();
mApp.Visible = true;// false;
Document mDoc = mApp.Documents.Add(DirPath + @"docs\中期汇报表.doc"); #region 填写表格
mDoc.Tables[1].Cell(1, 2).Range.Text = "控制科学与工程学院";
mDoc.Tables[1].Cell(1, 4).Range.Text = "测控技术与仪器";
mDoc.Tables[1].Cell(2, 2).Range.Text = Student.name;
mDoc.Tables[1].Cell(2, 4).Range.Text = Student.Teacher.Name;
mDoc.Tables[1].Cell(3, 2).Range.Text = Issue.Title;
if (Summary != null)
{
string s1 = "", s2 = "";
{
string[] temp = new string[1];
temp[0] = "\r\n";
string[] stringList = Summary.Split(temp, StringSplitOptions.RemoveEmptyEntries);
int[] rowList = new int[stringList.Length];
int rowAll = 0, rowAllOne = 0, bestrow;
for (int i = 0; i < rowList.Length; i++)
{
rowLioust[i] = CreatWord.RowOfPara(stringList[i], 29);
rowAll += rowList[i];
}
rowAll = rowAll * 15 / (15 + 12);
for (bestrow = 0; bestrow < rowList.Length; bestrow++)
if (rowList[bestrow] < rowAll - rowAllOne)
rowAllOne += rowList[bestrow];
else
if (rowAllOne + rowList[bestrow] - rowAll <= rowAll - rowAllOne)
break;
else
{
bestrow--;
break;
}
for (int i = 0; i < rowList.Length; i++)
if (i <= bestrow)
{
if (s1.Length != 0)
s1 += temp[0];
s1 += stringList[i];
}
else
{
if (s2.Length != 0)
s2 += temp[0];
s2 += stringList[i];
}
}
mDoc.Tables[1].Cell(4, 2).Range.Text = s1;
mDoc.Tables[2].Cell(1, 2).Range.Text = s2;
}
if (Comment != null)
mDoc.Tables[2].Cell(2, 2).Range.Text = Comment;
if (Sign)
{
Range place = mDoc.Tables[2].Cell(3, 2).Range.Characters.Last;
place = mDoc.Range(place.End - 1, place.End - 1);
CreatWord.SIGN(mDoc, place, Student.TeacherID);
}
if (FillDate != null)
mDoc.Paragraphs.Last.Range.Characters.Last.Text = ((DateTime)FillDate).ToString("yyyy年MM月dd日");
#endregion 填写表格 mDoc.SaveAs2(DirPath + @"docs\" + this.ID + ".doc");
mDoc.Close();
mApp.Quit();
mDoc = null;
mApp = null;
}
这里面都什么意思能不能详细解释解释啊啊
{
string DirPath = "";
{
HttpContext HttpCurrent = HttpContext.Current;
if (HttpCurrent != null)
DirPath = HttpCurrent.Server.MapPath("~");
else
DirPath = AppDomain.CurrentDomain.BaseDirectory;
if (DirPath[DirPath.Length - 1] != '\\')
DirPath += @"\";
}
Application mApp = new Application();
mApp.Visible = true;// false;
Document mDoc = mApp.Documents.Add(DirPath + @"docs\中期汇报表.doc"); #region 填写表格
mDoc.Tables[1].Cell(1, 2).Range.Text = "控制科学与工程学院";
mDoc.Tables[1].Cell(1, 4).Range.Text = "测控技术与仪器";
mDoc.Tables[1].Cell(2, 2).Range.Text = Student.name;
mDoc.Tables[1].Cell(2, 4).Range.Text = Student.Teacher.Name;
mDoc.Tables[1].Cell(3, 2).Range.Text = Issue.Title;
if (Summary != null)
{
string s1 = "", s2 = "";
{
string[] temp = new string[1];
temp[0] = "\r\n";
string[] stringList = Summary.Split(temp, StringSplitOptions.RemoveEmptyEntries);
int[] rowList = new int[stringList.Length];
int rowAll = 0, rowAllOne = 0, bestrow;
for (int i = 0; i < rowList.Length; i++)
{
rowLioust[i] = CreatWord.RowOfPara(stringList[i], 29);
rowAll += rowList[i];
}
rowAll = rowAll * 15 / (15 + 12);
for (bestrow = 0; bestrow < rowList.Length; bestrow++)
if (rowList[bestrow] < rowAll - rowAllOne)
rowAllOne += rowList[bestrow];
else
if (rowAllOne + rowList[bestrow] - rowAll <= rowAll - rowAllOne)
break;
else
{
bestrow--;
break;
}
for (int i = 0; i < rowList.Length; i++)
if (i <= bestrow)
{
if (s1.Length != 0)
s1 += temp[0];
s1 += stringList[i];
}
else
{
if (s2.Length != 0)
s2 += temp[0];
s2 += stringList[i];
}
}
mDoc.Tables[1].Cell(4, 2).Range.Text = s1;
mDoc.Tables[2].Cell(1, 2).Range.Text = s2;
}
if (Comment != null)
mDoc.Tables[2].Cell(2, 2).Range.Text = Comment;
if (Sign)
{
Range place = mDoc.Tables[2].Cell(3, 2).Range.Characters.Last;
place = mDoc.Range(place.End - 1, place.End - 1);
CreatWord.SIGN(mDoc, place, Student.TeacherID);
}
if (FillDate != null)
mDoc.Paragraphs.Last.Range.Characters.Last.Text = ((DateTime)FillDate).ToString("yyyy年MM月dd日");
#endregion 填写表格 mDoc.SaveAs2(DirPath + @"docs\" + this.ID + ".doc");
mDoc.Close();
mApp.Quit();
mDoc = null;
mApp = null;
}
这里面都什么意思能不能详细解释解释啊啊
解决方案 »
- 我的vs2010安装和部署没有模板
- 模板列删除问题
- ASP.net和ASP 在用户的角度考虑 都有什么样的区别?
- 问个input注册事件问题
- 将sql的数据显示在gridview中,更改了gridview中的数据,为什么sql中的数据不能更改?
- 怎么学习webservice ?
- 不能对word文档进行在线编辑。。。。。。。。
- 关于从客户端中检测到有潜在危险的 Request.Form 值很怪的问题?
- 如果在frame框架中一个子页面刷新另外一个子页面?
- "磁盘空间不足。"错误,.NET BUG ????????????500分!!!!!!!!!!!!!!
- Decorator模式 出现了点问题!。。
- 关于一个background的问题
rowlist什么意思》?
HttpContext详见
http://msdn.microsoft.com/zh-cn/library/system.web.httpcontext_members(v=VS.80).aspx