Tag: ip地址

在Excel电子表格中将variables与值匹配

我有一个代码,我input一个IP地址,我希望它find它的电子表格中的结束匹配的子网,我已经附上,有一个全面的子网。 基本上,将input的值在电子表格的单元格中find最接近的值并打印到控制台。 这里是我的代码,我注释了几行,所以我可以testing,如果电子表格链接正确。 Excel表格中只有2列。 A列和B列。细胞一直向下数千行。 using System; using System.Net; using Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel; using System.Data.OleDb; using System.Data; using System.Runtime.InteropServices; namespace Investigations { class Program { static void Main(string[] args) { int rCnt = 0; int cCnt = 0; string str; IPAddress addr = IPAddress.Parse("8.8.8.8"); IPHostEntry entry = Dns.GetHostEntry(addr); Console.WriteLine("IP Address: " + addr); […]

如何匹配确切的string值或与Excel列单元格最接近的匹配

我有一个inputIP地址的代码,然后它将循环search该IP的excel列中最接近的匹配项。 它只是循环每一个IP,我怎么把它的论点匹配的IP? using System; using System.Net; using Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel; using System.Data.OleDb; using System.Data; using System.Runtime.InteropServices; using System.Text.RegularExpressions; namespace Investigations { class Program { static void Main(string[] args) { IPAddress addr = IPAddress.Parse("8.8.8.8"); IPHostEntry entry = Dns.GetHostEntry(addr); Console.WriteLine("IP Address: " + addr); Console.WriteLine("Host Name: " + entry.HostName); Excel.Application xlApp = new Excel.Application(); Excel.Workbook […]

将string值匹配到导入的Excel表单元格

我很确定我真的接近了这个想法。 我有一个导入的Excel文档中的数千个IP地址。 我input一个IP,我想要它,所以程序匹配的IP地址与Excel表中最接近的IP地址,然后打印到控制台。 我认为我的问题是在我parsing工作表的第一个if语句中。 任何帮助将不胜感激。 我得到一个错误消息未处理的exception:System.NullReferenceException:对象引用不是一个对象的实例。 然后给出我的excel表单的path,后面是我认为是第一个if语句的exception。 using System; using System.Net; using Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel; using System.Data.OleDb; using System.Data; using System.Runtime.InteropServices; using System.Text.RegularExpressions; namespace Investigations { class Program { static void Main(string[] args) { IPAddress addr = IPAddress.Parse("8.8.8.8"); IPHostEntry entry = Dns.GetHostEntry(addr); Console.WriteLine("IP Address: " + addr); Console.WriteLine("Host Name: " + entry.HostName); Excel.Application […]

从csv中删除重复项并在Java中计数

我试图从我的路由器创build的日志文件中获取文本行,并将其分解为一个csv文件,以便查看。 来自日志文件的示例行: [VPN-IPSEC rule not match] from 192.168.1.254:63991 to 8.8.8.8:53 Wednesday, January 06,2016 08:52:18 我希望最终文件有规则,IP地址向内,端口向内,IP地址出,端口出,主机名,date和连接数量(重复)列。 public static void main(String[] args) throws UnknownHostException, IOException { PrintStream diskwriter = new PrintStream("C:\\Users\\admin\\Desktop\\RawIPs.csv"); diskwriter.print("Rule" + ","); diskwriter.print("Host Name" + ","); diskwriter.print("IP Address" + ","); diskwriter.println("Port"); int count = 0; try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\admin\\Desktop\\IPs.txt"))) { String line; […]

按包含IP地址的列对电子表格进行sorting(每个单元一个IP地址)

使用默认sorting引擎,以下列表被视为sorting: 10.0.0.219 10.0.0.22 10.0.0.223 这是不正确的。 分类应该是: 10.0.0.22 10.0.0.219 10.0.0.223 假设前三个八位字节是静态的是不安全的。 例如,其他IP地址包括: 10.35.10.11 10.28.66.30

将string值匹配到导入的Excel电子表格中的值

我正在尝试input一个IP地址,将匹配我的Excel中的一个IP spreadhseet。 它开始崩溃在DataRow行= xlWorksheet.Rows [i]; 线。 我需要它循环,因为我正在处理数以千计的IP和子网,并且它需要匹配CLOSEST IP。 我在想这可能不会在电子表格中提取所有单元格? 因为input的IP地址是一个stringvariables,当我使用我注释的代码来显示所有列时,它将获得所有的列。 System; using System.Net; using Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel; using System.Data.OleDb; using System.Data; using System.Runtime.InteropServices; using System.Text.RegularExpressions; namespace Investigations { class Program { static void Main(string[] args) { int rCnt = 0; int cCnt = 0; string str; IPAddress addr = IPAddress.Parse("8.8.8.8"); IPHostEntry entry = […]

在VBA cells.replace中使用通配符

我正在写一个函数在Excel中添加前缀零组成一个IP地址的八位组:例如在172.19.1.17我想改变.19。 到.019。,.1。 到.001。,而.17到.017。 Te Cells.Teplace函数似乎不接受? 作为通配符。 另外,有没有一种方法可以表示“string结尾”,因此我可以在上面的例子中将前导零添加到最后一个八位字节中。 谢谢伊恩 Cells.Replace What:=".1?.", Replacement:=".01?.", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False 这确实发现“10”。 “11.” “12”。 等等,但用“.01?”替代。