我在哪里可以找到从c#代码到tally的导出数据

时间:2016-04-04 09:52:03

标签: c# .net xml excel

我正在研究一种工具,通过将excel转换为tally xml格式,将数据从excel导出到tally,它通过localhost导出到tally,但我不知道数据的导出位置

以下代码显示了它如何转换并发送以下代码调用函数

private void button1_Click(object sender, EventArgs e)
{
        string excelfileName = tbXmlView.Text;
        DataSet TallyCollectionDataSet = TallyTest.ConnectToTally(excelfileName);
        MessageBox.Show("finished" + excelfileName);
}

此代码称为

public static DataSet ConnectToTally( string request)
{
        RequestXML = request;
        TallyRequest = WebRequest.Create("http://localhost:9000/");
        ((HttpWebRequest)TallyRequest).UserAgent = ".NET Framework Example Client";
        // Set the Method property of the request to POST.
        TallyRequest.Method = "POST";
        // Create POST data and convert it to a byte array.
        string postData = RequestXML;
        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        // Set the ContentType property of the WebRequest.
        TallyRequest.ContentType = "application/x-www-form-urlencoded";
        // Set the ContentLength property of the WebRequest.
        TallyRequest.ContentLength = byteArray.Length;
        // Get the request stream.
        Stream dataStream = TallyRequest.GetRequestStream();
        // Write the data to the request stream.
        dataStream.Write(byteArray, 0, byteArray.Length);
        // Close the Stream object.
        dataStream.Close();
        // Get the response.
        WebResponse response = TallyRequest.GetResponse();
        // Display the status.
        string Response = (((HttpWebResponse)response).StatusDescription).ToString();
        // Get the stream containing content returned by the server.
        dataStream = response.GetResponseStream();
        // Open the stream using a StreamReader for easy access.
        StreamReader reader = new StreamReader(dataStream);

        // Read the content.
        string responseFromTallyServer = reader.ReadToEnd().ToString();

        // Display the content.
        string ResponseFromtally=responseFromTallyServer.ToString();

        DataSet TallyResponseDataSet = new DataSet();
        TallyResponseDataSet.ReadXml(new StringReader(responseFromTallyServer));

        // Clean up the streams.
        reader.Close();
        dataStream.Close();
        response.Close();
        byteArray = null;
        response = null;
        responseFromTallyServer = null;
        Response = null;
        dataStream = null;
        RequestClient.open("Get", "http://localhost:9000/", false, null, null);

        IXMLDOMNode ResponseXml = (IXMLDOMNode)RequestClient.responseXML;
        RequestClient.send("helloworld");
        Console.WriteLine(RequestClient.responseText);
        return TallyResponseDataSet;
    }

0 个答案:

没有答案