如何在XML电子表格2003中插入图片/图像 [英] How to insert a picture/ image in XML spreadsheet 2003

查看:397
本文介绍了如何在XML电子表格2003中插入图片/图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以让我知道如何在XML电子表格2003中处理图像.我有一个excel文件,我将其另存为XML电子表格,并根据PHP代码对其中的值进行操作.现在,我想要将公司徽标放在我目前找不到任何解决方案的顶部..
任何帮助,将不胜感激..

致谢

Can anyone kindly let me know how to manipulate an image in XML spreadsheet 2003. I have an excel file which i am saving as an XML spreadsheet and i am manipulating the values in it based on the PHP code.. Now i want to place the company logo on the top for which i couldnt find any solution as of now..
Any help would be appreciated..

Thanks and Regards

推荐答案

ExcelLibrary是开放源代码项目,提供了与Microsoft Excel通讯的本机.NET功能.这意味着您将不再需要COM来创建XLS电子表格.

也可以在XLS电子表格中嵌入任何类型的图像.
ExcelLibrary is open source project that provides native .NET features to comunicate with Microsoft Excel. It means that you will not need COM to create XLS spreadsheet anymore.

There is a way to embed any kind of image in a XLS spreadsheet also.
string file = "C:\\temp\\newdoc.xls";
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("First Sheet");
worksheet.Cells[0, 1] = new Cell((short)1);
worksheet.Cells[2, 0] = new Cell(2.8);
worksheet.Cells[3, 3] = new Cell((decimal)3.45);
worksheet.Cells[2, 2] = new Cell("Text string");
worksheet.Cells[2, 4] = new Cell("Second string");
worksheet.Cells[4, 0] = new Cell(32764.5, "#,##0.00");
worksheet.Cells[5, 1] = new Cell(DateTime.Now, @"YYYY\-MM\-DD");
worksheet.Cells.ColumnWidth[0, 1] = 3000;
Picture pic = new Picture();
pic.Image = ExcelLibrary.SpreadSheet.Image.FromFile("C:\\temp\\myLogo.png");
pic.TopLeftCorner = new CellAnchor(5, 1, 0, 0);
pic.BottomRightCorner = new CellAnchor(12, 5, 592, 243);
worksheet.AddPicture(pic);
workbook.Worksheets.Add(worksheet);
workbook.Save(file);


如您所见,上面的代码填充了一些单元格并插入了PNG图像.

记住也要定义这些名称空间:


As you can see the code above fill some cells and insert a PNG image.

Remember to define those namespaces as well:

using ExcelLibrary.CompoundDocumentFormat;
using ExcelLibrary.BinaryDrawingFormat;
using ExcelLibrary.BinaryFileFormat;
using ExcelLibrary.SpreadSheet;



寻求 http://code.google.com/p/excellibrary/ [



Seek for http://code.google.com/p/excellibrary/[^] to get further information.


这篇关于如何在XML电子表格2003中插入图片/图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆