求女郎蜘蛛蜘蛛侠4百度云资源源

如何将excel表格里的一个数据比较大的表格能粘贴到word里_excel吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:135,240贴子:
如何将excel表格里的一个数据比较大的表格能粘贴到word里收藏
我有一个比较大的excel表格数据想弄到word里但是每次粘贴都很大,有很多都显示不出来,我就是想让表格能适合到word里,就像出报告一样,打印出来能到见所有数据,哪个大神的教教我呗
文档翻译,年终钜惠!注册就送268元体验金!
把表格弄小点呗
excel可以打印。而且更方便调整大小。
excel选择性粘贴可以把复制的区域粘贴为类似于矢量图的,图片。你在excel可以复制区域粘贴成图,然后复制粘贴到word里边缩小一些。
粘贴到Word,设置表格为自动适应纸张宽度
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或OFFICE(2)
Word(26)
Excel(28)
C# 如何将Excel表格复制到Word中并保留格式
在以前的文章中,我分享了,在本篇文章中我将介绍如何将Excel表格复制到Word表格中,并同时保留原Excel表格的格式。
这里我们需要使用到一个组件,叫做。它是一个企业级的Office组件,包含了Spire.Doc, Spire XLS, Spire.Spreadsheet, &Spire.Presentation,
Spire.PDF, Spire.DataExport, Spire.OfficeViewer, Spire.PDFViewer, Spire.DocViewer和Spire.BarCode等组件,使用它我们可以实现在.NET应用程序中查看、操作、转换及打印Office文档,PDF文档,创建Barcode以及数据导入导出等工作。这里我们需要使用到的是其中的Spire.Doc和Spire.XLS组件。
首先,下载并安装,然后打开Visual Studio,创建项目并引用Spire.Doc.dll和Spire.Xls.dll。以下是我们需要用到的命名空间:
using Spire.D
using Spire.Doc.D
using Spire.Doc.F
using Spire.X
详细步骤如下:
步骤1:从系统加载Excel文件并获取它的第一个工作表。
Workbook workbook = new Workbook();
workbook.LoadFromFile(&DatatableSample.xlsx&);
Worksheet sheet = workbook.Worksheets[0];步骤2:创建一个新的Word文档,添加一个表格并设置它的行列数与Excel表格中的行列数一致。
Document doc = new Document();
//添加表格
Table table = doc.AddSection().AddTable(true);
//设置行列数
table.ResetCells(sheet.LastRow, sheet.LastColumn);步骤3:将Excel表格中的数据写入到word表格里,并调用自定义的方法CopyStyle()将Excel表格中的格式复制到word表格。
for (int r = 1; r &=sheet.LastR r++)
for (int c = 1; c &= sheet.LastC c++)
CellRange xCell =sheet.Range[r, c];
TableCell wCell =table.Rows[r - 1].Cells[c - 1];
//将数据写入到word表格
TextRange textRange =wCell.AddParagraph().AppendText(xCell.NumberText);
//复制格式到word表格
CopyStyle(textRange,xCell, wCell);
}自定义的方法CopyStyle(TextRange wTextRange,CellRangexCell,TableCell wCell)如下:
wTextRange: Word表格中的文本
&xCell: Excel表格中的单元格
wCell: Word表格中的单元格
private static void CopyStyle(TextRangewTextRange, CellRange xCell, TableCell wCell)
//复制字体格式
wTextRange.CharacterFormat.TextColor= xCell.Style.Font.C
wTextRange.CharacterFormat.FontSize= (float)xCell.Style.Font.S
wTextRange.CharacterFormat.FontName= xCell.Style.Font.FontN
wTextRange.CharacterFormat.Bold= xCell.Style.Font.IsB
wTextRange.CharacterFormat.Italic= xCell.Style.Font.IsI
//复制背景颜色
wCell.CellFormat.BackColor= xCell.Style.C
//复制文本排列方式
switch(xCell.HorizontalAlignment)
case HorizontalAlignType.Left:
wTextRange.OwnerParagraph.Format.HorizontalAlignment= HorizontalAlignment.L
case HorizontalAlignType.Center:
wTextRange.OwnerParagraph.Format.HorizontalAlignment= HorizontalAlignment.C
case HorizontalAlignType.Right:
wTextRange.OwnerParagraph.Format.HorizontalAlignment= HorizontalAlignment.R
步骤4:保存文档。
doc.SaveToFile(&result.docx&,Spire.Doc.FileFormat.Docx);运行结果:
完整代码:
using Spire.D
using Spire.Doc.D
using Spire.Doc.F
using Spire.X
namespace 复制Excel表格到Word并保留格式
class Program
static void Main(string[] args)
//加载Excel文档
Workbook workbook = newWorkbook();
workbook.LoadFromFile(&DatatableSample.xlsx&);
Worksheet sheet = workbook.Worksheets[0];
//创建一个新的word文档
Document doc = newDocument();
//添加一个表格到word文档
Table table = doc.AddSection().AddTable(true);
//设置word表格的行列数
table.ResetCells(sheet.LastRow, sheet.LastColumn);
for (int r = 1; r&= sheet.LastR r++)
for (intc = 1; c &= sheet.LastC c++)
CellRange xCell = sheet.Range[r, c];
TableCell wCell = table.Rows[r -1].Cells[c - 1];
//将Excel表格中的数据写入到word表格
TextRangetextRange = wCell.AddParagraph().AppendText(xCell.NumberText);
//将Excel表格中的格式复制到word表格
CopyStyle(textRange, xCell, wCell);
//设置word表格的列宽
for (int i = 0; i& table.Rows.C i++)
for (intj = 0; j & table.Rows[i].Cells.C j++)
table.Rows[i].Cells[j].Width = 60f;
//保存文档并打开
doc.SaveToFile(&result.docx&,Spire.Doc.FileFormat.Docx);
System.Diagnostics.Process.Start(&result.docx&);
private static void CopyStyle(TextRangewTextRange, CellRange xCell, TableCell wCell)
//复制Excel单元格的字体格式到word表格
wTextRange.CharacterFormat.TextColor = xCell.Style.Font.C
wTextRange.CharacterFormat.FontSize = (float)xCell.Style.Font.S
wTextRange.CharacterFormat.FontName = xCell.Style.Font.FontN
wTextRange.CharacterFormat.Bold = xCell.Style.Font.IsB
wTextRange.CharacterFormat.Italic = xCell.Style.Font.IsI
//复制Excel单元格的背景颜色到word表格
wCell.CellFormat.BackColor =xCell.Style.C
//复制Excel单元格的字体排列方式到word表格
switch (xCell.HorizontalAlignment)
case HorizontalAlignType.Left:
wTextRange.OwnerParagraph.Format.HorizontalAlignment = HorizontalAlignment.L
case HorizontalAlignType.Center:
wTextRange.OwnerParagraph.Format.HorizontalAlignment = HorizontalAlignment.C
case HorizontalAlignType.Right:
wTextRange.OwnerParagraph.Format.HorizontalAlignment = HorizontalAlignment.R
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:56594次
积分:1479
积分:1479
排名:千里之外
原创:89篇
评论:42条
(3)(5)(5)(2)(5)(4)(1)(3)(2)(3)(4)(3)(4)(4)(5)(2)(3)(5)(5)(5)(4)(1)(5)(5)(10)君,已阅读到文档的结尾了呢~~
把excel表格复制到word中调整光出现错误怎么办
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
把excel表格复制到word中调整光出现错误怎么办
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

我要回帖

更多关于 蜘蛛侠1~3百度云资源 的文章

 

随机推荐