zoukankan      html  css  js  c++  java
  • 解决了Excel的一个貌似很奇怪的问题~~~

    1.  本来已经设计好Excel表头和表身的格式,我想要的效果是:



    2.  在SQL中直接向Excle写入数据:
    Insert Into OpenRowSet('Microsoft.Jet.OLEDB.4.0','Excel 5.0;HDR=YES;DataBase=E:\Cai\5in22\Template\5in22.xls',走势图$)
    select R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,R20,R21,R22,T_NO from T_5in22 order by t_no
    说明:
       T_5in22的结构是:
    CREATE TABLE T_5in22_ZST (T_no Varchar(10not null,
    R1 
    Varchar(10not null default(''),R2 Varchar(10not null default(''),
    R3 
    Varchar(10not null default(''),R4 Varchar(10not null default(''),
    R5 
    Varchar(10not null default(''),R6 Varchar(10not null default(''),
    R7 
    Varchar(10not null default(''),R8 Varchar(10not null default(''),
    R9 
    Varchar(10not null default(''),R10 Varchar(10not null default(''),
    R11 
    Varchar(10not null default(''),R12 Varchar(10not null default(''),
    R13 
    Varchar(10not null default(''),R14 Varchar(10not null default(''),
    R15 
    Varchar(10not null default(''),R16 Varchar(10not null default(''),
    R17 
    Varchar(10not null default(''),R18 Varchar(10not null default(''),
    R19 
    Varchar(10not null default(''),R20 Varchar(10not null default(''),
    R21 
    Varchar(10not null default(''),R22 Varchar(10not null default(''))
       数据呈现(Sql Server中):



    3.  结果得到(Excel中):


    硬是不明白为什么会这样,太奇怪了!!
    硬是搞了我半天~~~~~~ 最后,才明白原因所在!


    原来... ....
    Excel也会"继承":
    1. 表身的设计被废弃了,表身直接"继承"表头的格式.
    2. 如果表身和表头之间出现"断格",则"断格"之后的单元格就失去了对表头的"继承",转而套用Excel默认的格式.
        也就是说表T_5in22中,不能出现为空或者为NULL.



    ok, 更改Excle表头格式 & 更改表结构:
    CREATE TABLE T_5in22 (T_no Varchar(10not null,
    R1 
    Varchar(10not null default('.'),R2 Varchar(10not null default('.'),
    R3 
    Varchar(10not null default('.'),R4 Varchar(10not null default('.'),
    R5 
    Varchar(10not null default('.'),R6 Varchar(10not null default('.'),
    R7 
    Varchar(10not null default('.'),R8 Varchar(10not null default('.'),
    R9 
    Varchar(10not null default('.'),R10 Varchar(10not null default('.'),
    R11 
    Varchar(10not null default('.'),R12 Varchar(10not null default('.'),
    R13 
    Varchar(10not null default('.'),R14 Varchar(10not null default('.'),
    R15 
    Varchar(10not null default('.'),R16 Varchar(10not null default('.'),
    R17 
    Varchar(10not null default('.'),R18 Varchar(10not null default('.'),
    R19 
    Varchar(10not null default('.'),R20 Varchar(10not null default('.'),
    R21 
    Varchar(10not null default('.'),R22 Varchar(10not null default('.'))

    得到(Excel中):


    问题解决了!! 

    虽然有N多"小不点", 不过完全不影响    ^_^~          

  • 相关阅读:
    本地项目上传到github
    linux 常用命令
    mysql 查询日志基本操作
    js 短信60秒倒计时
    windows下 mysql 移库
    INSERT INTO table(xxx) VALUES (xxx)
    springboot 项目接口调用失败
    P1093 奖学金
    P1403约数研究
    P1147连续自然数和
  • 原文地址:https://www.cnblogs.com/tohen/p/750340.html
Copyright © 2011-2022 走看看