Exemplo n.º 1
0
        private void button2_Click(object sender, RibbonControlEventArgs e)
        {
            string url = @"http://www.matrix67.com/blog/feed";
            string txt = MyGrab.GetContent(url);

            System.Windows.Forms.MessageBox.Show(txt);
        }
Exemplo n.º 2
0
        //private static RibbonFunctionGrab _func = new RibbonFunctionGrab();
        //public static RibbonFunctionGrab Default
        //{
        //    get { return _func; }
        //}
        //private RibbonFunctionGrab() { }


        public static void Grab()
        {
            try
            {
                string        url = @"http://www.matrix67.com/blog/feed";
                List <string> txt = MyGrab.GetContents(url);

                Excel.Worksheet sheet = Geter.App.ActiveSheet;

                sheet.Cells[2, 1] = "序号";
                sheet.Cells[2, 2] = "标题";
                for (int i = 1; i <= txt.Count; i++)
                {
                    sheet.Cells[i + 2, 1] = i;
                    sheet.Cells[i + 2, 2] = txt[i - 1];
                }
                sheet.Range["a1:b1"].EntireColumn.AutoFit();
                sheet.Range["a2"].EntireColumn.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;

                sheet.Cells[1, 1] = url;
                sheet.Range["a1"].HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            }
            catch (Exception ex)
            {
                Logger.Default.Log(ex);
            }
        }
Exemplo n.º 3
0
 private void btnGetText_Click(object sender, EventArgs e)
 {
     Excel.Range rng = Globals.ThisAddIn.Application.Range["a1"];
     if (url != null)
     {
         string[] str = MyGrab.GetContent(url); //提取网抓内容
         //string[] strArr =str.Split('_');//分割成数组
         rng.ExportDataInSht <string>(str);     //输出到Excel单元格
         rng.EntireColumn.AutoFit();            //自动调整列宽
     }
 }
Exemplo n.º 4
0
        private void button3_Click(object sender, RibbonControlEventArgs e)
        {
            //string url1 = @"http://www.matrix67.com/blog/feed";
            //Excel.Range rng = (Excel.Range)Globals.ThisAddIn.Application.Selection;
            //rng.Value = MyGrab.GetContent(url1);
            //rng.AutoFitRange(100);

            string url2 = @"http://blog.sina.com.cn/rss/1748013412.xml";

            Excel.Range rng = (Excel.Range)Globals.ThisAddIn.Application.Selection;
            rng.Value = MyGrab.GetContent(url2);
            rng.AutoFitRange(100);
        }