|
本帖最后由 苏悉 于 2016-5-15 11:47 编辑
处于保护自己源代码的目的, 最近在学习VSTO, 学的太娘的累的。 就连一个简单的单元格赋值都总是不对, 网上也没有什么教材。真抓狂!
谁能帮看看下面代码到底是哪错了? 运行没提示错误但是也怎么也显示不了我要的结果..
public partial class Sheet1
{
object o = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
private void Sheet1_Startup(object sender, System.EventArgs e)
{
Excel._Application app = o as Excel._Application;
Excel.Workbook wb = (Excel.Workbook)app.ActiveWorkbook; //得到当前活动的excel文档
Excel.Worksheet MainSht = (Excel.Worksheet)wb.Sheets["交货登记表"];
Excel.Worksheet sht = (Excel.Worksheet)wb.Sheets["供应商信息"];
Excel.Range rng = (Excel.Range)MainSht.Cells[24, 1];
MainSht.Cells[24, 2].value = System.DateTime.Now;
rng.Value2 = "sadasdasd";
}
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
}
|
|