小编Moh*_*d K的帖子

如何使用openxml添加分节符下一页?

我想在文档的末尾添加一个分节符并添加一些文本.

我的代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

namespace WordDocManipulation
{
    class Program
    {
        static void Main(string[] args)
        {

            string path = @"C:\sample.docx";
            string strtxt = "Hello This is done by programmatically";      

           OpenAndAddTextToWordDocument(path,strtxt);
        }
        public static void OpenAndAddTextToWordDocument(string filepath, string txt)
        {
            /* I want to the below text to be added in the new section */ 

            // Open a WordprocessingDocument for editing using the filepath.
            WordprocessingDocument wordprocessingDocument =
                WordprocessingDocument.Open(filepath, true);

            // Assign a …
Run Code Online (Sandbox Code Playgroud)

c# ms-word openxml

9
推荐指数
2
解决办法
1万
查看次数

如何在asp.net中使用C#获取IP地址

我想在我的代码中获取访问者的公共 IP 地址。

我写了下面的代码来获取它:

        var context = System.Web.HttpContext.Current;
        string ip = String.Empty;

        if (context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
        {
            ip = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
        }
        else if (!String.IsNullOrWhiteSpace(context.Request.UserHostAddress))
        {
            ip = context.Request.UserHostAddress;                
        }

        if (ip == "::1")
            ip = "127.0.0.1";

        return ip;
Run Code Online (Sandbox Code Playgroud)

我没有得到确切的 IP 地址它返回的值如下:fe80::9419:dfb3:22ce:4e88%68但是当我在什么是我的 IP 中看到我的 IP 时它显示13.67.58.30。我将如何获得确切的 IP 地址?

c# asp.net ip

5
推荐指数
1
解决办法
6659
查看次数

发生错误:"生成报告时无法加载文件或程序集'Microsoft.Reportviewer.Winforms Version = 10.0.0.0"

我使用.net 4.0创建了一个应用程序,其中有两种形式.第一个表单接受来自用户的数据,第二个表单包含生成帐单的报表查看器控件.

数据输入表单的图像是这样的

生成的账单的图像是这个

由于我想在不同的计算机系统上运行这个应用程序,我使这个应用程序兼容.net 3.5框架.

它已成功转换,但单击"打印"按钮时会发生此错误.

请帮我解决这个错误怎么办?

提前致谢.

.net-4.0 visual-studio-2010 .net-3.5 reporting-services

4
推荐指数
1
解决办法
2万
查看次数

出现错误.. 无法加载文件或程序集“System.Drawing,Version 4.0.0.0, Culture=natural...”从 .net 4.0 转换为 .net 3.5 时出错

我是 Windows 桌面应用程序开发的新手。

我使用visual-studio 2010 创建了一个应用程序,其中我使用了一个表单进行数据输入。一种带有报表查看器控件和用于绘制报表的报表 (.rdlc) 文件的表单。

我的问题是我想让我的应用程序与 dot net framework 3.5 兼容。为此,我已将项目属性中的“高级编译选项...”中的目标框架更改为 3.5。但是在将目标框架更改为 3.5 后运行应用程序时出现错误是:

Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Line 123, position 5. C:\Users\Amir\Desktop\Bill_System\Bill_System\Bill_System\My Project\Resources.resx Billing_System

如何解决这个错误?

请帮忙。提前致谢。

.net-4.0 visual-studio-2010 .net-3.5 vb.net-2010

2
推荐指数
1
解决办法
2万
查看次数