C#怎么把Ilist中的内容转换为byte[],最近在做一个npoi导出excel文件中的图片问题,感觉挺麻烦的,谢谢大家~~~
解决方案 »
- url重写时参数的区分问题
- 实在是没办法了,很简单单太怪异的问题了...
- 鼠标在柱形图不同位置 表格内显示不同数据 如何实现【求助!!】
- ASP.NET页面将功能代码放在cs文件中和放在WebService中对功能的执行速度是不是没有影响?
- 怎么给href动态赋值?
- 新人请教两个问题:1、怎么做使用数据库做登陆的系统?2:页面不能跳转,时好时坏
- 能否实现双击datagrid进入另一个页,在哪个事件里写呢?都是绑定列可以吗?
- 如何在asp.net2.0中使用TreeView显示指定物理路径的文件夹及子文件夹?
- DataBinding:“System.Data.Common.DataRecordInternal”不包含名为“XX”的属性(在线等待、、)
- 高分请教:关于水晶报表
- 修饰符static对该项无效
- 两道软件测试题目,请帮忙哈...
BinaryFormatter bf = New BinaryFormatter();
MyClass mc = new MyClass();
bf.Serialize(fs, mc);
fs.Close(); 参考
读excel;
IList pictureList = wb.GetAllPictures();
取图片信息;下面我不会了
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== *//* ================================================================
* Author: Tony Qu
* Author's email: tonyqus (at) gmail.com
* NPOI HomePage: http://www.codeplex.com/npoi
* Contributors:
*
* ==============================================================*/using System;
using System.Collections.Generic;
using System.Text;using System.IO;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;
using System.Collections;
using System.Drawing;namespace ExtractPicturesFromXls
{
class Program
{
static void Main(string[] args)
{
InitializeWorkbook(); IList pictures = hssfworkbook.GetAllPictures();
int i = 0;
foreach (HSSFPictureData pic in pictures)
{
string ext = pic.SuggestFileExtension();
if (ext.Equals("jpeg"))
{
Image jpg = Image.FromStream(new MemoryStream(pic.Data));
jpg.Save(string.Format("pic{0}.jpg",i++));
}
else if (ext.Equals("png"))
{
Image png = Image.FromStream(new MemoryStream(pic.Data));
png.Save(string.Format("pic{0}.png", i++));
} } } static HSSFWorkbook hssfworkbook;
static void InitializeWorkbook()
{
FileStream file = new FileStream(@"clothes.xls", FileMode.Open, FileAccess.Read);
hssfworkbook = new HSSFWorkbook(file);
}
}
}
string ext = pic.SuggestFileExtension();
if (ext.Equals("jpeg"))
{
System.Drawing.Image jpg = System.Drawing.Image.FromStream(new MemoryStream(pic.Data));
jpg.Save(string.Format("pic{0}.jpg",i++));
}