zoukankan      html  css  js  c++  java
  • Excel表格写入操作函数 C++

    #pragma once
    #include <stdio.h>  
    #include <string.h>
    
    typedef unsigned short ushort;
    class ExcelProcess
    {
    public:
        ExcelProcess(void){pf=NULL;};
        ~ExcelProcess(void){ if (pf) EndWrite(); };
        
        void WriteCell(ushort row, ushort col, const char *value)
        {
            ushort iLen = (ushort)strlen(value);
            ushort clData[] = { 0x0204, ushort(8 + iLen), row, col, 0, iLen };
            WriteArray(clData, 12);
            WriteArray(value, iLen);
        }
    
        void WriteCell(ushort row, ushort col, int value)
        {
            ushort clData[] = { 0x027E, 10, row, col, 0 };
            WriteArray(clData, 10);
            int iValue = (value << 2) | 2;
            WriteArray(&iValue, 4);
        }
    
        void WriteCell(ushort row, ushort col, double value)
        {
            ushort clData[] = { 0x0203, 14, row, col, 0 };
            WriteArray(clData, 10);
            WriteArray(&value, 8);
        }
    
        void WriteCell(ushort row, ushort col)
        {
            ushort clData[] = { 0x0201, 6, row, col, 0x17 };
            WriteArray(clData, 10);
        }
    
        bool BeginWrite(const char *fileName)
        {
            pf = fopen(fileName, "wb+");
            if (!pf) return false;
            ushort clBegin[] = { 0x0809, 0x08, 0x0, 0x10, 0x0, 0x0 };
            WriteArray(clBegin, 12);
            return true;
        }
    
        void EndWrite()
        {
            ushort clEnd[] = { 0x0A, 0x0 };
            WriteArray(clEnd, 4);
            fclose(pf);
            pf = 0;
        }
        bool IsOpen()
        {
            if (pf!=NULL)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        void WriteArray(const void *value, ushort len)
        {
            if (pf)
                fwrite(value, 1, len, pf);
        }
    private:
        FILE *pf;
    };


    自己开发了一个股票智能分析软件,功能很强大,需要的点击下面的链接获取:

    https://www.cnblogs.com/bclshuai/p/11380657.html

    百度云盘下载地址:

    链接:https://pan.baidu.com/s/1swkQzCIKI3g3ObcebgpIDg

    提取码:mc8l

    微信公众号获取最新的软件和视频介绍

    QStockView

  • 相关阅读:
    Placing Rooks-CF 1342E
    Yet Another Counting Problem-CF 1342C
    [SDOI2016]齿轮
    Rinne Loves Xor
    Labyrinth CodeForces
    Nastya and Scoreboard
    Teacher Bo HDU
    Blood Cousins Return
    D Tree HDU
    设计模式学习笔记(八、行为型-策略模式)
  • 原文地址:https://www.cnblogs.com/bclshuai/p/7763768.html
Copyright © 2011-2022 走看看