1、打开wps文字,新建一个空白文档,在其中输入要" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > office365 > 如何添加Microsoft.Office.Interop.E...-net office.excel,microsoft

如何添加Microsoft.Office.Interop.E...-net office.excel,microsoft

作者:乔山办公网日期:

返回目录:office365


是不是安装了WPS,用WPS自带的卸载程序卸载,就可以了

1、打开wps文字,新建一个空白文档,在其中输入要zd求的文字。

2、同时,输入要添加引用的链接。

3、在导航栏中找到“引用->交叉引用”。

4、在“交叉引用”窗口中可以看到引用类型和引用内容等。

5、选择合适的链接引用,点击“插入”即可。

6、引用添加成功如图所示。


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;

using System.Data;
using System.IO;
using System.Text;

using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;
//using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

Object missing = Missing.Value;

Microsoft.Office.Interop.Excel.Application m_objExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbooks m_objWorkBooks = m_objExcel.Workbooks;

Microsoft.Office.Interop.Excel.Workbook m_objWorkBook = m_objWorkBooks.Add(true);
Microsoft.Office.Interop.Excel.Sheets m_objWorkSheets = m_objWorkBook.Sheets; ;
Microsoft.Office.Interop.Excel.Worksheet m_objWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)m_objWorkSheets[1];
m_objExcel.Visible = true;

// Range range1 = m_objWorkSheet.get_Range("A2", "E8");//选择操作块
m_objExcel.Caption = "收支平衡报表";
//try
//{
// m_objExcel.Save("e:129.xls");
//}
//catch (Exception e)
//{

//}
//finally
//{
// m_objWorkBooks.Close();
// m_objExcel.Quit();
//}

// m_objExcel.Cells[1, 1] = "建筑节能评估计算报告书";//第一行第一列文赋值

// m_objExcel.Cells[1, 1] = "建筑节能评估计算报告书";
m_objExcel.get_Range(m_objExcel.Cells[1, 1], m_objExcel.Cells[1, 4]).Font.Size = 20;
Microsoft.Office.Interop.Excel.Range range1 = m_objExcel.get_Range(m_objExcel.Cells[1, 1], m_objExcel.Cells[4,7]);
// range1.Merge(Type.Missing);//合并单元格

m_objExcel.get_Range(m_objExcel.Cells[1, 2], m_objExcel.Cells[1, 4]).Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue );//设置字体颜色
m_objExcel.get_Range(m_objExcel.Cells[1, 2], m_objExcel.Cells[1, 2]).Value2 = "2010年西安市财政局债务收支平衡表";//给合并的单元格赋值

m_objExcel.Cells.Columns.HorizontalAlignment = XlHAlign.xlHAlignCenter; //设置文本水平居中 成功e79fa5e98193e78988e69d83338
// m_objExcel.Cells[4, 5] = "单位:万元";
range1.Merge(Type.Missing);//合并单元格

// Range range1 = m_objWorkSheet.get_Range("A7", "A9");//选择操作块
Microsoft.Office.Interop.Excel.Range range8 = m_objExcel.get_Range("A7", "A9");//(m_objExcel.Cells[7, 1], m_objExcel.Cells[9,1])也行
//range8.HorizontalAlignment = XlHAlign.xlHAlignLeft; //设置文本水平居左 成功
//Range range8 = m_objWorkSheet.get_Range("A2", "E8");//选择操作块

range8.Font.Bold = true;//设置黑体

range8.Font.Size = 15;//设置字体大小

range8.Font.Name = "仿宋";//设置字体

range8.Font.Color = System.Drawing.ColorTranslator.ToOle(Color.Blue);//设置字体颜色

range8.HorizontalAlignment = XlHAlign.xlHAlignLeft;//设置水平对齐方式

range8.VerticalAlignment = XlVAlign.xlVAlignCenter;//设置垂直对齐方式

//////////////行////////////////////////////////////////////////////////////////////////////////////////
m_objExcel.get_Range(m_objExcel.Cells[5, 2], m_objExcel.Cells[5, 7]).Font.Size = 15;
Microsoft.Office.Interop.Excel.Range range2 = m_objExcel.get_Range(m_objExcel.Cells[5, 2], m_objExcel.Cells[5, 4]);
range2.Merge(Type.Missing);//合并单元格
Microsoft.Office.Interop.Excel.Range range3 = m_objExcel.get_Range(m_objExcel.Cells[5, 5], m_objExcel.Cells[5, 7]);
range3.Merge(Type.Missing);//合并单元格
Microsoft.Office.Interop.Excel.Range range4 = m_objExcel.get_Range(m_objExcel.Cells[5, 1], m_objExcel.Cells[6, 1]);
range4.Merge(Type.Missing);//合并单元格
m_objExcel.get_Range(m_objExcel.Cells[5, 2], m_objExcel.Cells[5, 7]).Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);//设置字体颜色
m_objExcel.get_Range(m_objExcel.Cells[5, 2], m_objExcel.Cells[5, 2]).Value2 = "收入";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[5, 5], m_objExcel.Cells[5, 5]).Value2 = "支出";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[5, 1], m_objExcel.Cells[6, 1]).Value2 = "债务人";//给合并的单元格赋值
// m_objExcel.Cells[4, 5] = "单位:万元";
range1.Merge(Type.Missing);//合并单元格

m_objExcel.get_Range(m_objExcel.Cells[6, 2], m_objExcel.Cells[6, 2]).Value2 = "合计";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[6, 3], m_objExcel.Cells[6, 3]).Value2 = "上年转借数";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[6, 4], m_objExcel.Cells[6, 4]).Value2 = "当年举借数";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[6, 5], m_objExcel.Cells[6, 5]).Value2 = "合计";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[6, 6], m_objExcel.Cells[6, 6]).Value2 = "当年支出数";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[6, 7], m_objExcel.Cells[6, 7]).Value2 = "结转下年数";//给合并的单元格赋值

///////列//////////////////////////////////////////////////////////////////////////////////////////////

m_objExcel.get_Range(m_objExcel.Cells[7, 1], m_objExcel.Cells[7, 1]).Value2 = "合计";//给合并的单元格赋值
m_objExcel.get_Range(m_objExcel.Cells[8, 1], m_objExcel.Cells[8, 1]).Value2 = "一.直接债务";//给合并的单元格赋值

///////////////////////////////////////////////////////////////////////////////

m_objExcel.get_Range(m_objExcel.Cells[1, 2], m_objExcel.Cells[1, 4]).Font.Size = 20;
//m_objExcel.Cells[1, 1] = "建筑节能评估计算报告书";
m_objExcel.get_Range(m_objExcel.Cells[1, 1], m_objExcel.Cells[9,7]).Borders.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue);//设置边框颜色

m_objExcel.get_Range(m_objExcel.Cells[1, 1], m_objExcel.Cells[4, 1]).ColumnWidth = 40;//设置宽度.get_Range(excel.Cells[1, 1], excel.Cells[4, 1]).ColumnWidth = 20;//设置宽度

m_objExcel.get_Range(m_objExcel.Cells[5, 2], m_objExcel.Cells[5, 7]).ColumnWidth = 18;//设置宽度

//m_objExcel.Cells.Columns.HorizontalAlignment = XlHAlign.xlHAlignCenter; //设置文本水平居中 成功

///range1.VerticalAlignment = XlVAlign.xlVAlignCenter;//设置垂直对齐方式

range1.Font.Bold = true;//粗体
range1.Interior.ColorIndex = 15;//背景颜色
range1.EntireRow.AutoFit();//自动调整行高
// range1.Merge(Type.Missing);//合并单元格

}

public object xlCenter { get; set; }
}

// range1.HorizontalAlignment = m_objExcel.XlHAlign.xlHAlignCenter;//居中 不行
//m_objExcel.Cells.Columns.HorizontalAlignment = m_objExcel.XlHAlign.xlHAlignCenter; //不行

好像不太简单,不过可以读出数据来自己添加样式。

相关阅读

  • <em>Microsoft</em> Office <em>Excel</em

  • 乔山办公网excel表格制作
  • 应该可以的啊,你安装的真的是07版的? 附: 方案一 (安装Office 2010企业版):e68a84e799bee5baa6e79fa5e98193333 Microsoft Office 2010 Pro VOL简体中文正式版+迷你KMS激活:活: http:///office-2010-k
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网