JXCELL实例学习与研究(四) 之 录入数据、绘制表格、修整线性表的颜色 密码的设置与破译

简介:

注释部分就不注释了,我都做了笔记,而且内网部分的东西拿不出来


EXCEL录入数据,并且根据录入的数据制图,且修整线性表的颜色

import com.jxcell.*;

import java.awt.*;

public class ChartFormatTest
{
    public static void main(String args[])
    {

        View m_view = new View();

        RangeRef newRange = null;

        try {
            m_view.getLock();
            m_view.setTextAsValue(1,2,"Jan");
            m_view.setTextAsValue(1,3,"Feb");
            m_view.setTextAsValue(1,4,"Mar");
            m_view.setTextAsValue(1,5,"Apr");
            m_view.setTextAsValue(2,1,"Bananas");
            m_view.setTextAsValue(3,1,"Papaya");
            m_view.setTextAsValue(4,1,"Mango");
            m_view.setTextAsValue(5,1,"Lilikoi");
            m_view.setTextAsValue(6,1,"Comfrey");
            m_view.setTextAsValue(7,1,"Total");

            m_view.setTextAsValue(1,6,"time");
            m_view.setNumber(2,6,1);
            m_view.setNumber(3,6,2);
            m_view.setNumber(4,6,3);
            m_view.setNumber(5,6,4);
            m_view.setNumber(6,6,5);
            m_view.setNumber(7,6,6);

            for(int col = 2; col <= 5; col++)
                for(int row = 2; row <= 7; row++)
                    m_view.setFormula(row, col, "rand()");
            m_view.setFormula(7, 2, "SUM(C3:C7)");
            m_view.setSelection("C8:F8");
            m_view.editCopyRight();

            ChartShape chart = m_view.addChart(0, 9.1, 7, 20.4);

            chart.setChartType(ChartShape.TypeLine);
//            chart.setLinkRange("Sheet1!$C$2", false);

            chart.addSeries();
            chart.setSeriesName(0, "Sheet1!$C$2");
            chart.setSeriesYValueFormula(0, "Sheet1!$C$3:$C$7");
            chart.setCategoryFormula("Sheet1!$B$3:$B$7");

            chart.addSeries();
            chart.setSeriesName(1, "Sheet1!$D$2");
            chart.setSeriesYValueFormula(1, "Sheet1!$D$3:$D$7");

            chart.addSeries();
            chart.setSeriesName(2, "Sheet1!$E$2");
            chart.setSeriesYValueFormula(2, "Sheet1!$E$3:$E$7");

            chart.addSeries();
            chart.setSeriesName(3, "Sheet1!$F$2");
            chart.setSeriesYValueFormula(3, "Sheet1!$F$3:$F$7");

//            chart.getChart().validateData();

            chart.setAxisTitle(ChartShape.XAxis, 0, "Category");
            chart.setAxisTitle(ChartShape.YAxis, 0, "Amount");

            // set fill color
            ChartFormat cf = chart.getChartFormat();
            cf.setPattern((short)1);
            cf.setPatternFG(Color.LIGHT_GRAY.getRGB());
            chart.setChartFormat(cf);

            cf = chart.getPlotFormat();
            cf.setPattern((short)1);
            cf.setPatternFG(new Color(204, 255, 255).getRGB());
            chart.setPlotFormat(cf);

            cf = chart.getAxisFormat(ChartShape.XAxis, 0);
            cf.setFontSizeInPoints(8.5);
            chart.setAxisFormat(ChartShape.XAxis, 0, cf);

            cf = chart.getAxisFormat(ChartShape.YAxis, 0);
            cf.setFontSizeInPoints(8.5);
            chart.setAxisFormat(ChartShape.YAxis, 0, cf);

            cf = chart.getSeriesFormat(0);
            cf.setLineStyle((short)1);
            cf.setLineWeight(3*20);
            cf.setLineColor((new Color(0, 0, 128)).getRGB());
            cf.setMarkerAuto(false);
            cf.setMarkerStyle((short)0);
            chart.setSeriesFormat(0, cf);

            cf = chart.getSeriesFormat(1);
            cf.setLineStyle((short)1);
            cf.setLineWeight(3*20);
            cf.setLineColor((new Color(255, 0, 255)).getRGB());
            cf.setMarkerAuto(false);
            cf.setMarkerStyle((short)0);
            chart.setSeriesFormat(1, cf);

            cf = chart.getSeriesFormat(2);
            cf.setLineStyle((short)1);
            cf.setLineWeight(3*20);
            cf.setLineColor((new Color(255, 255, 0)).getRGB());
            cf.setMarkerAuto(false);
            cf.setMarkerStyle((short)0);
            chart.setSeriesFormat(2, cf);

            cf = chart.getSeriesFormat(3);
            cf.setLineStyle((short)1);
            cf.setLineWeight(3*20);
            cf.setLineColor((new Color(0, 255, 255)).getRGB());
            cf.setMarkerAuto(false);
            cf.setMarkerStyle((short)0);
            chart.setSeriesFormat(3, cf);

            cf = chart.getMajorGridFormat(ChartShape.YAxis, 0);
            cf.setLineStyle((short)2);
            cf.setLineColor((new Color(255, 0, 0)).getRGB());
            cf.setLineAuto();
            chart.setMajorGridFormat(ChartShape.YAxis, 0, cf);

            chart.setLegendPosition(ChartFormat.LegendPlacementTop);

            cf = chart.getLegendFormat();
            cf.setFontBold(true);
            cf.setFontSizeInPoints(8);
            chart.setLegendFormat(cf);

            m_view.write(".\\out.xls");
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
        finally
        {
            m_view.releaseLock();
        }
    }
}



密码的设置与破译

import com.jxcell.View;
import com.jxcell.CellException;

import java.io.IOException;

public class EncryptDecrypt
{
    public EncryptDecrypt()
    {
        encrypt();
        decrypt();
    }

    public void encrypt()
    {
        View m_view = new View();
        try
        {
            m_view.setTextAsValue(1,2,"Jan");
            m_view.setTextAsValue(1,3,"Feb");
            m_view.setTextAsValue(1,4,"Mar");
            m_view.setTextAsValue(1,5,"Apr");
            m_view.setTextAsValue(2,1,"Bananas");
            m_view.setTextAsValue(3,1,"Papaya");
            m_view.setTextAsValue(4,1,"Mango");
            m_view.setTextAsValue(5,1,"Lilikoi");
            m_view.setTextAsValue(6,1,"Comfrey");
            m_view.setTextAsValue(7,1,"Total");
            for(int col = 2; col <= 5; col++)
                for(int row = 2; row <= 7; row++)
                    m_view.setFormula(row, col, "RAND()");
            m_view.setFormula(7, 2, "SUM(C3:C7)");
            m_view.setSelection("C8:F8");
            m_view.editCopyRight();

            //set the workbook open password
            m_view.write(".\\encrypt.xls", "hi");
        }
        catch (CellException e)
        {
            e.printStackTrace();
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }

    public void decrypt()
    {
        View m_view = new View();
        try
        {
            //read the encrypted excel file
            m_view.read(".\\encrypt.xls", "hi");

            //write without password protected
            m_view.write(".\\decrypt.xls");
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

    public static void main(String args[])
    {
        new EncryptDecrypt();
    }
}






目录
相关文章
|
3月前
|
Linux iOS开发 MacOS
【随手记】maplotlib.use函数设置图像的呈现方式
【随手记】maplotlib.use函数设置图像的呈现方式
34 0
|
4月前
【word】论文、报告:①插入图表题注,交叉引用②快速插入图表目录③删改后一键更新
【word】论文、报告:①插入图表题注,交叉引用②快速插入图表目录③删改后一键更新
545 0
|
4月前
OEEL——使用OEEL快速画出精美图案(以土地利用转移变化为例)
OEEL——使用OEEL快速画出精美图案(以土地利用转移变化为例)
30 0
|
人工智能 编解码 移动开发
当「分割一切」遇上图像修补:无需精细标记,单击物体实现物体移除、内容填补、场景替换(2)
当「分割一切」遇上图像修补:无需精细标记,单击物体实现物体移除、内容填补、场景替换
113 0
|
计算机视觉
当「分割一切」遇上图像修补:无需精细标记,单击物体实现物体移除、内容填补、场景替换(1)
当「分割一切」遇上图像修补:无需精细标记,单击物体实现物体移除、内容填补、场景替换
130 0
|
前端开发
图形验证码验证行式的笔记
最近在做关于验证码项目的时候,从交互的角度梳理了验证码的验证行式,今天总结一下验证码在产品中出现的验证行式。
图形验证码验证行式的笔记
|
数据安全/隐私保护
一个页面多个图形验证码冲突的解决方案
实际开发中,经常会遇到一个页面需要两个或多个验证码,使用同一个验证码调用两次会导致前一个失效。那么我们需要使用两个不同的验证码.
一个页面多个图形验证码冲突的解决方案
|
前端开发
前端工作总结160-表格重置
前端工作总结160-表格重置
76 0
前端工作总结160-表格重置
|
Linux Python
Python编程:colorama给控制台文本增加颜色
Python编程:colorama给控制台文本增加颜色
121 0
Python编程:colorama给控制台文本增加颜色