//源Execl名称
string sourceExeclFileName = "C:\\SourceExecl.xlsx";
//目标Execl名称
string targetExeclFileName = "C:\\TargetExecl.xlsx";
using (ExcelPackage package = new ExcelPackage(new FileInfo(targetExeclFileName)))
{
	using (ExcelPackage sourcePackage = new ExcelPackage(new FileInfo(sourceExeclFileName)))
	{
		//new sheet form copy为复制到目标Execl的SheetName
		package.Workbook.Worksheets.Add("new sheet from copy", sourcePackage.Workbook.Worksheets[1]);
	}
	package.Save();
}

js 格式化数字,输出格式化后的字符串。

Number.prototype.format = function (format) {
    if (!format) {
        return this.toString();
    }
    var comma = ',',
                dec = '.',
                i18n = false,
                neg = v < 0;

    var v = Math.abs(this);
    if (format.substr(format.length - 2) == '/i') {
        format = format.substr(0, format.length - 2);
        i18n = true;
        comma = '.';
        dec = ',';
    }

    var hasComma = format.indexOf(comma) != -1,
                psplit = (i18n ? format.replace(/[^\d\,]/g, '') : format.replace(/[^\d\.]/g, '')).split(dec);

    if (1 < psplit.length) {
        v = v.toFixed(psplit[1].length);
    } else if (2 < psplit.length) {
        throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
    } else {
        v = v.toFixed(0);
    }

    var fnum = v.toString();

    psplit = fnum.split('.');

    if (hasComma) {
        var cnum = psplit[0],
                    parr = [],
                    j = cnum.length,
                    m = Math.floor(j / 3),
                    n = cnum.length % 3 || 3,
                    i;

        for (i = 0; i < j; i += n) {
            if (i != 0) {
                n = 3;
            }

            parr[parr.length] = cnum.substr(i, n);
            m -= 1;
        }
        fnum = parr.join(comma);
        if (psplit[1]) {
            fnum += dec + psplit[1];
        }
    } else {
        if (psplit[1]) {
            fnum = psplit[0] + dec + psplit[1];
        }
    }

    return (neg ? '-' : '') + format.replace(/[\d,?\.?]+/, fnum);
}

/// <summary>
/// 获取日期是第几周
/// </summary>
/// <param name="date">日期</param>
/// <returns>第几周</returns>
public static int GetWeekOfYear(DateTime date)
{
	//确定此时间在一年中的位置
	int dayOfYear = date.DayOfYear;
	//当年第一天
	DateTime tempDate = new DateTime(date.Year, 1, 1);
	//确定当年第一天
	int tempDayOfWeek = (int)tempDate.DayOfWeek;
	tempDayOfWeek = tempDayOfWeek == 0 ? 7 : tempDayOfWeek;
	//确定星期几
	int index = (int)date.DayOfWeek;
	index = index == 0 ? 7 : index;
	//当前周的范围
	DateTime retStartDay = date.AddDays(-(index - 1));
	DateTime retEndDay = date.AddDays(7 - index);
	//确定当前是第几周
	int weekOfYear = (int)Math.Ceiling(((double)dayOfYear + tempDayOfWeek - 1) / 7);
	if (retStartDay.Year < retEndDay.Year)
	{
		weekOfYear = 1;
	}
	return weekOfYear;
}

Wordpress 媒体设置界面

WordPress 3.5以上的版本,隐藏了后台的媒体(Media)设置页面 上传路径(upload_path)和文件 URL 地址(upload_url_path)的设定。

将下面的代码添加到主题的 functions.php 即可恢复设置界面:

if(get_option('upload_path')=='wp-content/uploads' || get_option('upload_path')==null) {
	update_option('upload_path',WP_CONTENT_DIR.'/uploads');
}

CentOS 7 源码安装 p11-kit,解决 configure: error: p11-kit >= 0.23.1 was not found. To disable PKCS #11 support 错误。

1、下载并解压

wget https://github.com/p11-glue/p11-kit/releases/download/0.23.16/p11-kit-0.23.16.tar.gz
tar -zxvf p11-kit-0.23.16.tar.gz
cd p11-kit-0.23.16

备用下载地址: https://down.24kplus.com/linux/p11-kit-0.23.16.tar.gz

2、编译安装

./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/p11-kit \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/p11-kit
make
make install

如果出现 configure: error: libtasn1 not found. Building without it results in significant loss of functionality. To proceed use --without-libtasn1 错误,执行:

yum install -y libtasn1-devel

如果出现 configure: error: Package requirements (libffi >= 3.0.0) were not met: No package 'libffi' found 错误,执行:

yum install -y libffi-devel

CentOS 7 源码安装 libidn2 最新版,解决 error while loading shared libraries: libidn2.so.4: cannot open shared object file: No such file or directory 错误

1、下载并解压

wget https://ftp.gnu.org/gnu/libidn/libidn2-latest.tar.gz
tar -zxvf libidn2-latest.tar.gz
cd libidn2*

2、编译安装

./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/libidn2 \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/libidn2 \
--with-packager \
--with-packager-version \
--with-packager-bug-reports
make
make install

CentOS 7 源码安装 openpts 0.2.6。

1、下载并解压

wget https://mirrors.xtom.com/osdn/openpts/54410/openpts-0.2.6.tar.gz
tar -zxvf openpts-0.2.6.tar.gz
cd openpts-0.2.6

备用下载地址:https://down.24kplus.com/linux/openpts-0.2.6.tar.gz

2、编译安装

./bootstrap.sh
./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/openpts \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/openpts \
--with-tss \
--with-aru \
--enable-tnc
make
make install

如果出现 /include/openpts.h:50:17: fatal error: tss.h: No such file or directory 错误,安装:

yum install trousers-devel

如果出现 fatal error: uuid.h: No such file or directory 错误,安装:

yum install e2fsprogs-devel uuid-devel libuuid-devel

CentOS 7 源码安装 tpm-tools 1.3.9.1

1、下载并解压

mkdir tpm-tools
cd tpm-tools
wget https://nchc.dl.sourceforge.net/project/trousers/tpm-tools/1.3.9.1/tpm-tools-1.3.9.1.tar.gz
tar -zxvf tpm-tools-1.3.9.1.tar.gz

备用下载地址:https://down.24kplus.com/linux/tpm-tools-1.3.9.1.tar.gz

2、编译安装

./configure \
--prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/libexec \
--sysconfdir=/etc/tpm-tools \
--libdir=/usr/lib64 \
--includedir=/usr/include \
--datarootdir=/usr/share \
--infodir=/usr/share/info \
--localedir=/usr/local \
--mandir=/usr/share/man \
--docdir=/usr/share/doc/tpm-tools
make
make install

如果出现 configure: error: tss lib not found: libtspi.so 错误:

yum install trousers-devel

如果出现 configure: error: openssl lib not found: libcrypto.so 错误:

yum install openssl-devel