60能卖?能的话给我也留个言...
jdjdj...
用webgl+unity3d听我的...
为何登录后出现下列问题?请高手指点。
你调试下吧 ,你报的错是空指针异常 AO1表 没有,你看下你的数据库连接的有没有问题,或数据库
您好,我刚也遇到这个问题,我已经解决了,将Microsoft.Office.Interop.Word.Tables.Items[index]改成Microsoft.Office.Interop.Word.Tables[index]就可以了。如果不能解决联系我,QQ:**********
using System;<br/>using System.Collections.Generic;<br/>using System.ComponentModel;<br/>using System.Data;<br/>using System.Drawing;<br/>using System.Text;<br/>using System.Windows.Forms;<br/>using System.Data.SqlClient;<br/>using System.IO;<br/><br/>namespace WindowsApplication2<br/>{<br/> public partial class Form1 : Form<br/> {<br/> public Form1()<br/> {<br/> InitializeComponent();<br/> }<br/> private void button1_Click(object sender, EventArgs e)<br/> {<br/> ExportToWord();<br/> }<br/> public void GetTempFileName()<br/> {<br/> <br/> }<br/> public void ExportToWord()<br/> {<br/> string c;<br/> SqlConnection myConn = new SqlConnection(connectionString);<br/> myConn.Open();<br/> SqlDataAdapter sda = new SqlDataAdapter("select * from Theme", myConn);<br/> DataSet ds = new DataSet("ds");<br/> sda.FillSchema(ds, SchemaType.Mapped, "Theme");<br/> sda = new SqlDataAdapter("select * from Theme", myConn);<br/> sda.FillSchema(ds, SchemaType.Mapped, "Theme");<br/> sda.Fill(ds, "Theme");<br/> if (ds.Tables.Count != 0)<br/> {<br/> string tempFileName = null;<br/> object filename = null;<br/> object tableBehavior = Microsoft.Office.Interop.Word.WdDefaultTableBehavior.wdWord8TableBehavior; <br/> object autoFitBehavior = Microsoft.Office.Interop.Word.WdAutoFitBehavior.wdAutoFitFixed;<br/> object unit = Microsoft.Office.Interop.Word.WdUnits.wdStory;<br/> object extend = System.Reflection.Missing.Value;<br/> object breakType = (int)Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakNextPage;<br/> object count = 1;<br/> object character = Microsoft.Office.Interop.Word.WdUnits.wdCharacter;<br/> object Nothing = System.Reflection.Missing.Value;<br/> try<br/> {<br/> //tempFileName = GetTempFileName();<br/> <br/> //生成.doc完整路径名<br/> filename = "C:\\Program Files" + "asd" + ".doc";<br/> //创建一个WORD文件,文件名用系统时间生成精确到毫秒<br/> Microsoft.Office.Interop.Word.Application myWord = new Microsoft.Office.Interop.Word.ApplicationClass();<br/> Microsoft.Office.Interop.Word.Document myDoc = new Microsoft.Office.Interop.Word.DocumentClass();<br/> // myDoc = myWord.Documents.Add();<br/> myDoc.Activate();<br/> //向把dataset中的表插入到word文件中<br/> for (int totalTable = 0; totalTable < ds.Tables.Count; totalTable++)<br/> {<br/> myWord.Application.Selection.TypeText(ds.Tables[totalTable].TableName + "表的数据如下");<br/> myWord.Application.Selection.TypeParagraph();<br/> Microsoft.Office.Interop.Word.Range para = myWord.Application.Selection.Range;<br/> myDoc.Tables.Add(para, ds.Tables[totalTable].Rows.Count + 1, ds.Tables[totalTable].Columns.Count, ref tableBehavior, ref autoFitBehavior);<br/> for (int column = 0; column < ds.Tables[totalTable].Columns.Count; column++)<br/> {<br/> myDoc.Tables.Item(totalTable + 1).Cell(1, column+1).Range.InsertBefore(ds.Tables[0].Columns[column].ColumnName.Trim());<br/> }<br/> for (int row = 0; row < ds.Tables[totalTable].Rows.Count; row++)<br/> {<br/> for (int column = 0; column < ds.Tables[totalTable].Columns.Count; column++)<br/> {<br/> myDoc.Tables.Item(totalTable + 1).Cell(row + 2, column + 1).Range.InsertBefore(ds.Tables[totalTable].Rows[row][column].ToString().Trim());<br/> }<br/> }<br/> myWord.Application.Selection.EndKey(ref unit, ref extend);<br/> myWord.Application.Selection.TypeParagraph();//原程序此话写了两次<br/> myWord.Application.Selection.InsertBreak(ref breakType);<br/> }<br/> myWord.Application.Selection.TypeBackspace();<br/> myWord.Application.Selection.Delete(ref character, ref count);<br/> myWord.Application.Selection.HomeKey(ref unit, ref extend);<br/> //保存word文件到指定的目录下<br/> try<br/> {<br/> //myDoc.SaveAs(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);<br/> myWord.Visible = true;<br/> }<br/> catch<br/> {<br/> System.Windows.Forms.MessageBox.Show("系统找不到指定目录下的文件:" + "C:\\Program Files" + tempFileName + ".doc");<br/> return;<br/> }<br/> //让生成的word文件可见<br/> myWord.Visible = true;<br/> }<br/> catch (Exception ex)<br/> {<br/> System.Windows.Forms.MessageBox.Show("向word文件中写入数据出错:" + ex.Message);<br/> }<br/> }<br/> else<br/> {<br/> System.Windows.Forms.MessageBox.Show("没有数据");<br/> }<br/> }<br/> }<br/> }<br/><br/><br/>问题: 第80行:错误提示说:错误 1 “Microsoft.Office.Interop.Word.Tables”并不包含“Item”的定义 E:\rexian\WindowsApplication2\WindowsApplication2\Form1.cs 80 42 WindowsApplication2<br/> 该怎么办?