wsArray

VBA Excel入门:零基础实现办公自动化 Excel VBA是一种嵌入式自动化技术,依托Excel原生环境运行,无需额外安装依赖,具备即写即跑、调试直观、权限友好等工程优势。其核心在于对象模型(Workbook/Worksheet/Range)与事件驱动机制,适用于财务、供应链、教务等高频表格处理场景。相比Python或Power Automate,VBA在中小组织中仍具不可替代性——尤其当用户需‘零学习成本’快速解决重复操作,如自动填充编号、跨表核对、一键导出PDF等。本文聚焦真实工位需求,从激活开发工具、录制宏逆向学代码,到编写可落地的VBA脚 阅读详情
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace wsControls
{
    public class wsArray
    {
        #region [ Static ] GetFrequency, GetChanPower, PeakSearch, SortTrace ... To Verify
        public static decimal[] ApplyFrequency(decimal start, decimal stop, int nop)
        {
            decimal[] frequency = new decimal[nop];
            decimal span = stop - start;
            int interval = nop - 1;
            for (int i = 0; i < nop; i++)
                frequency[i] = start + i * span / interval;
            return frequency;
        }

        public static decimal GetValue(decimal start, decimal stop, decimal nop, decimal index)
        {
            decimal span = stop - start;
            return start + span * index / (nop - 1);
        }

        public static decimal GetValue(decimal[] array, decimal index)
        {
            return array[0] + (array[array.Length - 1] - array[0]) * index / (array.Length - 1);
        }

        public static decimal GetIndex(decimal start, decimal stop, int nop, decimal frequency)
        {
            decimal span = stop - start;
            return (frequency - start) * (nop - 1) / span;
        }

        public static decimal GetIndex(decimal[] array, decimal frequency)
        {
            return (frequency - array[0]) * (array.Length - 1) / (array[array.Length - 1] - array[0]);
        }

        public static double GetChanPower(decimal[] trace, int startindex, int stopindex)
        {
            double p = 0D;
            for (int i = startindex; i <= stopindex; i++)
            {
                p += Math.Pow(10D, (double)trace[i] / 10D);
            }

            return p < Math.Pow(10D, -17) ? -175 : 10 * Math.Log10(p);
        }

        public static decimal GetFlatnesss(decimal[] trace, int istart, int istop)
        {
            decimal max = trace[istart]; decimal min = trace[istart];
            for (int i = istart+1; i <= istop; i++)
            {
                if (trace[i] > max)
                {
                    max = trace[i];
                    continue;
                }
                if (trace[i] < min)
                    min = trace[i];
            }
            return max - min;
        }

        public static double GetChanPower(decimal[] trace, decimal span, decimal bandwidth)
        {
            decimal N = bandwidth * (trace.Length - 1) / span;
            N = N / 2;
            decimal istart = (trace.Length - 1) / 2 - N;
            decimal istop = (trace.Length - 1) / 2 + N;

            return GetChanPower(trace, (int)istart, istop - (int)istop > 0 ? (int)istop + 1 : (int)istop);
        }

        public static int[] SortMinMax(decimal[] trace)
        {//From Min to Max
            int[] index = new int[trace.Length];
            for (int i = 0; i < index.Length; i++)
                index[i] = i;

            decimal[] sort = (decimal[])trace.Clone();
            Array.Sort(sort, index, 0, index.Length);//from 0 -> N
            //Array.Reverse(index);
            return index;
        }

        public static int[] SortMinMax(Collection<decimal> trace)
        {//From Min to Max
            int[] index = new int[trace.Count];
            for (int i = 0; i < index.Length; i++)
                index[i] = i;

            decimal[] sort = (decimal[])trace.ToArray();
            Array.Sort(sort, index, 0, index.Length);//from 0 -> N
            //Array.Reverse(index);
            return index;
        }

        public static int[] SortMaxMin(decimal[] trace)
        {
            int[] index = SortMinMax(trace);
            Array.Reverse(index);
            return index;
        }

        public static decimal GetPeak(decimal[] trace, int istart, int istop)
        {
            decimal max = decimal.MinValue; 
            for (int i = istart; i <= istop; i++)
            {
                if (trace[i] > max)                
                    max = trace[i];                               
            }
            return max;
        }

        public static int[] GetPeakIndex(decimal[] trace, int npeaks)
        {
            int[] peakindex = new int[npeaks];

            int[] sortindex = SortMinMax(trace);
            int n = 0;


            int candidateindex;
            for (int i = sortindex.Length - 1; i >= 0 && n < npeaks; i--)
            {
                candidateindex = sortindex[i];//peak index, n starts from 0
                if (candidateindex == 0 )
                {
                    if (trace[candidateindex] >= trace[candidateindex + 1])
                    {
                        peakindex[n] = candidateindex;
                        n++;
                    }
                    continue;
                }
                else if (candidateindex == sortindex.Length - 1 )
                {
                    if (trace[candidateindex] >= trace[candidateindex - 1])
                    {
                        peakindex[n] = candidateindex;
                        n++;
                    }
                    continue;
                }
                else if (trace[candidateindex] >= trace[candidateindex - 1] && trace[candidateindex] >= trace[candidateindex + 1])
                {
                    peakindex[n] = candidateindex;
                    n++;
                    continue;
                }
            }
            return peakindex;
        }

        public static int[] GetPeakIndex(Collection<decimal> trace, int npeaks)
        {
            int[] peakindex = new int[npeaks];

            int[] sortindex = SortMinMax(trace);
            int n = 0;


            int candidateindex;
            for (int i = sortindex.Length - 1; i >= 0 && n < npeaks; i--)
            {
                candidateindex = sortindex[i];//peak index, n starts from 0
                if (candidateindex == 0)
                {
                    if (trace[candidateindex] >= trace[candidateindex + 1])
                    {
                        peakindex[n] = candidateindex;
                        n++;
                    }
                    continue;
                }
                else if (candidateindex == sortindex.Length - 1)
                {
                    if (trace[candidateindex] >= trace[candidateindex - 1])
                    {
                        peakindex[n] = candidateindex;
                        n++;
                    }
                    continue;
                }
                else if (trace[candidateindex] >= trace[candidateindex - 1] && trace[candidateindex] >= trace[candidateindex + 1])
                {
                    peakindex[n] = candidateindex;
                    n++;
                    continue;
                }
            }
            return peakindex;
        }
        #endregion
    }
}

【Web服务器运维】基于Nginx与Keepalived的高可用负载均衡系统部署:实现故障自动切换与虚拟IP管理 内容概要:本文详细介绍了如何通过Nginx与Keepalived实现高可用的负载均衡架构。首先讲解了Nginx的安装部署流程,包括依赖环境的准备、源码解压编译、启动及配置重载;接着介绍了Keepalived的安装步骤及其服务管理方式;重点在于通过配置Keepalived的主备节点(MASTER/BACKUP),结合VRRP协议和虚拟IP(VIP)实现故障自动切换,并通过自定义脚本nginx_check.sh实时检测Nginx运行状态,确保服务高可用;最后补充了在云环境中因组播限制导致心跳不稳定时,应改用单播(unicast)方式进行通信的解决方案。; 适合人群:具备Linux系统操作基础、熟悉网络基础知识,从事运维、DevOps或Web服务部署的技术人员,尤其是工作1-3年的工程师。; 使用场景及目标:①搭建高可用的Web负载均衡系统,避免单点故障;②掌握Nginx与Keepalived协同工作的原理与实战配置方法;③应用于生产环境中提升服务稳定性与容灾能力。; 阅读建议:学习时应结合实验环境动手操作,重点关注keepalived.conf配置差异与nginx_check.sh脚本逻辑,理解VRRP机制及单播替代组播的实际应用场景,注意根据实际网络环境调整IP与网卡参数。 立即下载

相关推荐

datart 二开环境搭建

下载源码, 地址: https://github.com/running-elephant/datart, dev 分支; 解压后使用 idea 打开; 服务端: 3.1 安装依赖, idea会自动安装; 3.2 修改配置文件 /config/application.yml 3.3 创建数据库,并将bin/datart.sql导入到数据库中 3.4 入口: /server/src/main/java/datart/DatartServerApplication.java [外链图片转存失败,源站可能有防.

又是再见? 6133

后缀数组(SuffixArray) 学习笔记

后缀数组     前面有介绍过后缀树,后缀树对于我们针对某些字符串的处理使得如鱼得水,美中不足的是后缀树的代码实现复杂,只能让很多人望而却步。这次我们来介绍后缀树组:一个处理字符串的有力工具,也是一个后缀树的精美替代品,同样可以方便解决很多字符串问题。它比后缀树更加容易实现编码,也可以在不损失效率的情况下实现很多后缀树的功能,占用内存也比后缀树小很多,尤其是在模式匹配数据规模庞大的操作中实用性很

尜尜君的小世界 3367

stata 代码实现熵值法计算 含常见问题解答

2.标准化①正向指标②负向指标。

m0_74825360的博客 1217

WebSocket 实战--转

原文地址:http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/ WebSocket 前世今生 众所周知,Web 应用的交互过程通常是客户端通过浏览器发出一个请求,服务器端接收请求后进行处理并返回结果给客户端,客户端浏览器将信息呈现,这种机制对于信息变化不是特别频繁的应用尚可,但对于实时要求高、海量并发的应用来说显得捉襟见肘,尤其...

weixin_30445169的博客 77

Circos图审美拯救计划:用TBtools复刻Nature级共线性分析图谱

本文针对Circos图在共线性分析中的审美提升问题,提供了一套基于TBtools的完整优化方案。通过构建和谐的色彩体系、精细控制信息层布局以及模仿顶刊构图逻辑,详细讲解了如何从配色、透明度、标签显示到高级参数设置,将默认图表升级为具有高级学术美感的Nature级图谱,助力研究者提升论文图表质量。

cherry的博客 911

JAVA + 海康威视SDK + FFmpeg+ SRS 实现海康威视摄像头二次开发

海康威视SDK接入方案摘要 本文介绍了使用海康威视官方SDK开发物联网平台摄像头接入功能的完整方案。系统采用Java后端集成HCNetSDK控制摄像头,通过FFmpeg将RTSP流转为RTMP推送到SRS流媒体服务器,前端基于HTTP-FLV协议实现视频播放。文章详细说明了开发准备工作,包括SDK下载、SRS部署、FFmpeg安装等关键步骤,并提供了数据库表设计和接口定义。核心部分展示了如何集成海康SDK,包括提取必要代码、加载DLL文件、配置打包插件等具体实现细节,最终形成了一套支持实时预览、回放和下载的

2401_83057947的博客 2263

C# 中的字体

C#中本来已经封装了通用字体Font,但是笔者认为这个Font在使用过程中很不方便。 1) Font的很多属性都是只读的,不能通过更改属性的值而对Font进行操作;必须重新初始化Font对象才行。例如:font.Size=12;是不允许的。 2) Font总归是用来写字的,但是C#中的Font类与string类没有什么联系,这给Font的使用带来了一些麻烦。比如我想要知道一个string对象使

WavesLine的专栏 1540

Python量化入门:用pytdx获取800个交易日K线数据的完整指南(附代码)

本文为Python量化交易初学者提供了使用pytdx库免费获取股票日线级别K线数据的完整指南。文章详细介绍了从环境搭建、单只股票数据获取,到构建健壮的批量下载器、数据清洗与验证,再到基础分析与可视化的全流程,并附有可直接运行的代码示例,帮助读者快速建立本地股票数据库。

weixin_29050513的博客 1465

FileAssociation

using System; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; using Microsoft.Win32; namespace wsWin { #region [ FileAssociation ] public class FileAssoci

WavesLine的专栏 1304

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 233

GEE 案例分析:利用Landsat数据进行FAI、NDVI及CHLA分析并统计平均值(巢湖为例)

浮游藻类指数(FAI)、归一化植被指数(NDVI)及叶绿素a(CHLA)是水体环境监测的重要指标。本文利用Google Earth Engine(GEE)平台,基于Landsat 5和Landsat 8数据,进行水体藻类及植被监测。

此星光明博客 1336

c# 后台程序

C# 中的backgroundworker,是我个人认为最具有吸引力的windows标准控件之一,他允许程序在后台运行一个独立的线程,而不影响前台主窗口。这种进程控制在操作数据库或通讯时非常实用,因为后台线程在工作时并不影响前台的任何操作。如果不使用backgroundworker而简单的应用单一线程操作,则通讯时很有可能会造成主窗口假死,知道通讯结束后才会恢复。下面简单介绍backgroundw

WavesLine的专栏 915

Codex 100个真实案例 - 用AI做股票K线分析工具(技术指标全自动)

本案例将用 Codex 从零搭建一个完整的股票 K 线分析工具。通过自然语言驱动,我们让 AI 自动完成股票数据获取(akshare)、K 线图绘制(mplfinance + ECharts)、技术指标计算(MA/EMA/MACD/RSI/KDJ/布林带)、买卖信号提示(金叉/死叉、超买超卖)、多股对比分析、Web 可视化界面(Flask + ECharts)、PDF 报告生成以及定时监控邮件推送等全套功能。全程用自然语言指令驱动 Codex,零手写代码实现专业级量化分析平台!

yueyeguzhuo的专栏 867

C# 打开外部文件

System.Diagnostics.Process.Start(".//Help.chm");

WavesLine的专栏 900

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

StringX

namespace wsControls { public class StringX { public static char mylar = (char)220; #region [ Property ] String public string String { get; set; } #endregion

WavesLine的专栏 897

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

CDataGrid

enum DataMask { Num, Float, Date, NvChar, Bit }; [ToolboxBitmap(typeof(System.Windows.Forms.DataGridView))] class CDataGrid : DataGridView { public DataMask val_type; publi

WavesLine的专栏 868

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

ListView 到 Excel

using System.Reflection; Function() { Excel.Application app = new Excel.Application(); if (app == null) { MessageBox.Show("Failed to Load Excel,Pleas

WavesLine的专栏 856

win32

using System; using System.Runtime.InteropServices; using System.Drawing; using System.Text; namespace wsWin { public class Win32 { public const int GW_HWNDFIRST = 0; public

WavesLine的专栏 766

读写文件

BackgroundWorker background1 = new BackgroundWorker();byte[] buffer1;//HDD -> MEM BackgroundWorker background2 = new BackgroundWorker();byte[] buffer2;//MEM -> HDD UInt32 pointer1, pointer2; bool abor

WavesLine的专栏 698

ini, Reg

using System.Text; using Microsoft.Win32; namespace wsWin { #region [ *.ini file ] public class InI { public string path; public InI(string INIPath) {

WavesLine的专栏 615

User Define Message

You need total 3 steps to define your message   [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar);   public const int UserMsg =

WavesLine的专栏 592

DataGrid导出到Ex el, 自动获取列标识

#region [ 导出到Excel ] public void Export() { #region range int count = this.Columns.Count; if (count > 256 || count == 0)//超出Excel的最大行数,

WavesLine的专栏 557

wsFile

using System; using System.Collections.ObjectModel; using System.Data; using System.Drawing; using System.IO; using System.Text; namespace wsControls.IO { public class wsFile { publi

WavesLine的专栏 526

读写操作,文件和注册表

using System; using System.Collections.Generic; using System.Linq; using Microsoft.Win32; using System.Text; 读写INI文件 public class InI { public string path; #region -- Dll I

WavesLine的专栏 514

Copy文件

private void bRun_Click(object sender, EventArgs e) { byte[] buffer; int blocksize = 4096; try { FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open);

WavesLine的专栏 485
上一篇: wsFile
下一篇: wsPlot
WavesLine
博客等级 码龄12年 18粉丝 58原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值