NPOI导出Excel,添加图片和设置格式,添加条形码
先上代码
using grproLib;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization; namespace shopeePrint
{
class Program
{
//static string ConnectionStr = "uid=gkweb_ticnL;pwd=gtIddQVVbSd89*@r%E;database=GBWMSDB;server=117.48.196.54,2859;Pooling=true;Min Pool Size=5;Max Pool Size=1000"; static void Main(string[] args)
{
string url = "https://sellercenter-api.jumia.com.ng/?";
//string Action = "FeedList";
string Action = "GetDocument";
string Format = "JSON";
string Timestamp = System.Web.HttpUtility.UrlEncode(DateTime.Now.AddDays(-).ToString("s") + "+0000", System.Text.Encoding.Default); ;
//string Timestamp = DateTime.Now.AddDays(-1).ToString("s") + "+0000";
string UserID = "jumia888999@gmail.com";
string Version = "1.0";
string Signature = "7c40abd44eeb21009edcb03f045360bdeec3a70d";
string DocumentType = "invoice";//'invoice', 'exportInvoice', 'shippingLabel', 'shippingParcel', 'carrierManifest', or "serialNumber".
string OrderItemIds = "[377847952]";
string str = string.Format("Action={0}&Format={1}&Timestamp={2}&UserID={3}&Version={4}&Signature={5}&DocumentType={6}&OrderItemIds={7}"
, Action, Format, Timestamp, UserID, Version, Signature,DocumentType, OrderItemIds);
//str = System.Web.HttpUtility.UrlEncode(str, System.Text.Encoding.Default);
string urlstr = url + str;
Console.WriteLine(urlstr);
Program.WriteLog(urlstr);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(urlstr);
string result = "";
try
{
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
Console.WriteLine(result);
Program.WriteLog(result);
}
}
catch (Exception err)
{
//msg = err.Message;
}
//string json = new JavaScriptSerializer().Serialize(param);
//string result = GetMessageResult(json, shoopurl, key, out msg);
//shopeeOrderList shooporders = new JavaScriptSerializer().Deserialize<shopeeOrderList>(result);
}
private static void WriteLog(string msg)
{ //当前程式目录创建Log目录
string path = AppDomain.CurrentDomain.BaseDirectory;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string fileName = DateTime.Now.ToString("yyyy-MM-dd"); string filepath = path + fileName + ".txt"; Stream fileStream = null;
StreamWriter writeAdapter = null;
fileStream = File.Open(filepath, FileMode.Append, FileAccess.Write, FileShare.Write);
writeAdapter = new StreamWriter(fileStream, System.Text.Encoding.UTF8);
writeAdapter.WriteLine("***********" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "************");
writeAdapter.WriteLine("Message::::" + msg);
writeAdapter.WriteLine("***********End*********************************************************");
writeAdapter.WriteLine(" ");
writeAdapter.Close();
} private static string GetMessageResult(string json , string url, string key, out string msg)
{
msg = "";
string input = string.Format("{0}|{1}", url.Replace(" ", ""), json.Replace(" ", ""));
HMACSHA256 hm256 = new HMACSHA256(ASCIIEncoding.ASCII.GetBytes(key));
byte[] hashBytes = hm256.ComputeHash(ASCIIEncoding.ASCII.GetBytes(input));
string authe = BitConverter.ToString(hashBytes).Replace("-", "").ToLower(); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(json);
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.Method = "POST";
httpWebRequest.Headers["Authorization"] = authe;
httpWebRequest.KeepAlive = false; Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(bytes, , bytes.Length);
requestStream.Close();
string result = "";
try
{
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
Program.WriteLog(result);
Console.WriteLine(result);
}
}
catch (Exception err)
{
msg = err.Message;
}
return result;
} } class FeedListParam
{
public string Action { get; set; }
public string Format { get; set; }
public string Timestamp { get; set; }
public string UserID { get; set; }
public string Version { get; set; }
public string Signature { get; set; }
public string CreatedAfter { get; set; }
public string CreatedBefore { get; set; }
public string Search { get; set; }
public string Filter { get; set; }
public string Limit { get; set; }
public string Offset { get; set; }
public string SkuSellerList { get; set; }
public string UpdatedAfter { get; set; }
public string UpdatedBefore { get; set; }
public string GlobalIdentifier { get; set; }
} }
项目引用NPOI
测试输出的Excel 显示条形码
设置边框
NPOI导出Excel,添加图片和设置格式,添加条形码的更多相关文章
- NPOI 导出excel带图片,可控大小
using NPOI.HSSF.UserModel;using NPOI.HSSF.Util;using NPOI.DDF;using NPOI.SS.UserModel;using System.I ...
- NPOI导出EXCEL部分样式不起作用
在使用NPOI导出excel的时候,设置cell样式,数据量多余6条之后,在后面几条数据没有样式(边框,对其,换行等). 原因是设置CellStyle的时候把CreateCellStyle放在循环列集 ...
- NPOI导出EXCEL 打印设置分页及打印标题
在用NPOI导出EXCEL的时候设置分页,在网上有查到用sheet1.SetRowBreak(i)方法,但一直都没有起到作用.经过研究是要设置 sheet1.FitToPage = false; 而 ...
- [转]NPOI导出EXCEL 打印设置分页及打印标题
本文转自:http://www.cnblogs.com/Gyoung/p/4483475.html 在用NPOI导出EXCEL的时候设置分页,在网上有查到用sheet1.SetRowBreak(i)方 ...
- NPOI导出excel(带图片)
近期项目中用到Excel导出功能,之前都是用普通的office组件导出的方法,今天尝试用下NPOI,故作此文以备日后查阅. 1.NPOI官网http://npoi.codeplex.com/,下载最新 ...
- NPOI导出Excel(含有超过65335的处理情况)
NPOI导出Excel的网上有很多,正好自己遇到就学习并总结了一下: 首先说明几点: 1.Excel2003及一下:后缀xls,单个sheet最大行数为65335 Excel2007 单个sheet ...
- NPOI导出EXCEL报_服务器无法在发送 HTTP 标头之后追加标头
虽然发表了2篇关于NPOI导出EXCEL的文章,但是最近再次使用的时候,把以前的代码粘贴过来,居然报了一个错误: “服务器无法在发送 HTTP 标头之后追加标头” 后来也查询了很多其他同学的文章,都没 ...
- .NET NPOI导出Excel详解
NPOI,顾名思义,就是POI的.NET版本.那POI又是什么呢?POI是一套用Java写成的库,能够帮助开发者在没有安装微软Office的情况下读写Office的文件. 支持的文件格式包括xls, ...
- 分享使用NPOI导出Excel树状结构的数据,如部门用户菜单权限
大家都知道使用NPOI导出Excel格式数据 很简单,网上一搜,到处都有示例代码. 因为工作的关系,经常会有处理各种数据库数据的场景,其中处理Excel 数据导出,以备客户人员确认数据,场景很常见. ...
随机推荐
- 浅谈JavaScript原型
在JavaScript中,所有函数都会拥有一个叫做prototype的属性,默认初始值为“空”对象(没有自身属性的对象). 1.原型属性 如下所示,简单地定义一个函数: function foo(a, ...
- Java Knowledge series 2
JVM Analysis & Design The object-oriented paradigm is a new and different way of thingking about ...
- js获取农历日期【转】
var CalendarData=new Array(100); var madd=new Array(12); var tgString="甲乙丙丁戊己庚辛壬癸"; var dz ...
- 夜色的 cocos2d-x 开发笔记 04
本章会把游戏的基本功能结束,前面实现了子弹发射,产生敌人. 接下来我们要,检测子弹与敌人碰撞,让玩家移动,实现这个游戏的基本功能. 于是多出了这几个方法,当然还是写在.h文件里 首先实现触摸监听的方法 ...
- Myeclipse与tomcat的运行问题
在myeclipse中修改自己servlet后,在次运行时,可能会没有变化,这时需要重启tomcat,重新加载servlet
- TP5.1:模板赋值与变量输出
模板赋值:assign() 模板渲染:fetch() 前提准备: 1.在app/index/controller下建立一个控制器,名为Templates.php,里面有test1和test2方法,并且 ...
- 1.06 在WHERE子句中引用取别名的列
如下查询,会抛出错误: mysql> select sal as salary, comm as commission from emp where salary < 5000;ERROR ...
- Win7多用户同时登陆
软件提供下载: http://pan.baidu.com/s/1o6FQv70
- Linux笔记(开机自动将kerne log保存到SD卡中)
有时候为了测试机器的稳定性,需要煲机测试几天的情况,这个时候机器已经封装好,不能再接串口线出来. 为了追溯问题,就需要将log信息保存下来. 于是就需要这样一个功能:系统启动后,自动将kernel的l ...
- MyEclipse中安装findBugs插件(摘)
安装方法如下: 1.首先从findbugs网站下载插件:http://findbugs.sourceforge.net/downloads.html 2.将下载回来的zip包解压,得到文件夹:edu. ...