找回密码
 立即注册

QQ登录

只需一步,快速开始

hoptech

注册会员

10

主题

21

帖子

182

积分

注册会员

积分
182

活字格认证微信认证勋章元老葡萄

hoptech
注册会员   /  发表于:2017-3-9 18:59  /   查看:3854  /  回复:5
   C1XLBook book = new C1XLBook();

   // step 2: get the sheet that was created by default, give it a name
   XLSheet sheet = book.Sheets[0];
   sheet.Name = "Hello World";
   // step 3: create styles for odd and even values
   XLStyle styleOdd    = new XLStyle(book);
   styleOdd.Font       = new Font("Tahoma", 9, FontStyle.Italic);
   styleOdd.ForeColor  = Color.Blue;
   XLStyle styleEven   = new XLStyle(book);
   styleEven.Font      = new Font("Tahoma", 9, FontStyle.Bold);
   styleEven.ForeColor = Color.Red;
   // step 3: write content and format into some cells
   for (int i = 0; i < 70000; i++)
   {

    XLCell cell = sheet[i, 0];
    cell.Value = i + 1;
    cell.Style = ((i+1) % 2 == 0)? styleEven: styleOdd;
   }
   // step 4: save the file
            string fileName = Application.StartupPath + @"\hello.xlsx";
            book.Save(fileName, C1.C1Excel.FileFormat.OpenXml);
   System.Diagnostics.Process.Start(fileName);

5 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2017-3-10 11:57:01
沙发
谢谢您的反馈。
微软的Excel2003版本有最大行数的限制,导出成Excel2003的时候,如果超过会有提示。
对于超过65536的最大行数,请您存成excel2007的格式
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
hoptech
注册会员   /  发表于:2017-3-13 12:53:28
板凳
根据以上代码,如何存成excel2007的格式?
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-3-13 13:51:37
地板
hoptech 发表于 2017-3-13 12:53
根据以上代码,如何存成excel2007的格式?

需要把CompatibilityMode改成非Excel2003.
比如:
  1. book.CompatibilityMode = CompatibilityMode.Excel2007;
  2. book.Save(tempdir + @"defaultWidth.xlsx");
复制代码

接口文档:
http://helpcentral.componentone. ... patibilityMode.html
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
hoptech
注册会员   /  发表于:2017-3-15 16:05:38
5#
谢谢了!
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-3-15 18:07:31
6#

不用客气。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部