Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将内容导入excel工作表_C#_Php_Sql - Fatal编程技术网

C# 将内容导入excel工作表

C# 将内容导入excel工作表,c#,php,sql,C#,Php,Sql,那天我想出了一些代码,可以把PDF文件下载到我的桌面上。它是用C写的 我正试图用PHP做同样的事情。我想知道是否有人有我尝试做的任何样本 我不确定是否能在Word中完成。我用Excel做过类似的事情 我试图采取一个Excel文件和抓取多个网站的内容 这些网站每隔半小时左右就会同时生成新的查询 我希望能够检索内容并将内容导入excel文件,以便尝试重新排列信息。阅读3到4个网站的内容,并将其下载到excel文件中,以尽可能使用表格组织内容 using System; using System.IO

那天我想出了一些代码,可以把PDF文件下载到我的桌面上。它是用C写的

我正试图用PHP做同样的事情。我想知道是否有人有我尝试做的任何样本

我不确定是否能在Word中完成。我用Excel做过类似的事情

我试图采取一个Excel文件和抓取多个网站的内容

这些网站每隔半小时左右就会同时生成新的查询

我希望能够检索内容并将内容导入excel文件,以便尝试重新排列信息。阅读3到4个网站的内容,并将其下载到excel文件中,以尽可能使用表格组织内容

using System;
using System.IO;
using System.Net;

static class Program
{
    static void Main()
    {
        string url = "http://www.uakron.edu/dotAsset/1265971.pdf", localPath = "1265971.pdf";

        var req = (HttpWebRequest)WebRequest.Create(url);
        req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
        req.Headers.Add("Accept-Encoding","gzip,deflate");
        if(File.Exists(localPath))
            req.IfModifiedSince = File.GetLastWriteTimeUtc(localPath);
        try
        {
            using (var resp = req.GetResponse())
            {
                int len;
                checked
                {
                    len = (int)resp.ContentLength;
                }
                using (var file = File.Create(localPath))
                using (var data = resp.GetResponseStream())
                {
                    byte[] buffer = new byte[4 * 1024];
                    int bytesRead;
                    while (len > 0 && (bytesRead = data.Read(buffer, 0, Math.Min(len, buffer.Length))) > 0)
                    {
                        len -= bytesRead;
                        file.Write(buffer, 0, bytesRead);
                    }
                }
            }
            Console.WriteLine("New version downloaded");
        }
        catch (WebException ex)
        {
            if (ex.Response == null || ex.Status != WebExceptionStatus.ProtocolError)
                throw;
            Console.WriteLine("Not updated");
        }
    }
}
我正在尝试开发一个有时间间隔的应用程序,这样我就可以确定在文件中生成新查询的时间。我正在尝试用php以内联样式格式生成代码。全部是一个脚本。而不是C#,它需要多个文件

这是我创建的一个求职网站。 (我不是想窃取内容。)


谢谢

我会直接从excel向您的网站发出一些http请求(例如csv格式)。然后,您可以按照您想要的方式使用信息(并使用时间戳来知道要更新的数据)

以下是excel中http get请求的示例: