DevExpress从SpreadsheetControl拷贝粘贴到richeditcontrol

            PropertyInfo propertyInfo = spreadsheetControl1.Document.Worksheets[0].Workbook.Options.Export.GetType().GetProperty("Html", BindingFlags.Instance | BindingFlags.NonPublic);
            object value = propertyInfo.GetValue(spreadsheetControl1.Document.Worksheets[0].Workbook.Options.Export, null);

            HtmlDocumentExporterOptions options = propertyInfo.GetValue(spreadsheetControl1.Document.Worksheets[0].Workbook.Options.Export, null) as HtmlDocumentExporterOptions;
            //propertyInfo = options.GetType().GetProperty("Range", BindingFlags.Instance | BindingFlags.NonPublic);
            //propertyInfo.SetValue(options, "$A$1:$B$2", null);

            options.Range = "$A$1:$L$30";
            MemoryStream ms = new MemoryStream();
            ms.Position = 0;

            byte[] bytes = spreadsheetControl1.Document.Worksheets[0].Workbook.SaveDocument(new DocumentFormat(6));
            Encoding encoding = options.Encoding;
            string htmlText = encoding.GetString(bytes);
            richEditControl1.BeginUpdate();
            richEditControl1.Document.InsertHtmlText(richEditControl1.Document.Range.Start, htmlText);
            richEditControl1.EndUpdate();
devexpress 14.1.17

你可能感兴趣的:(DevExpress应用)