读取本地excel发短信
package com.cmcc.zysoft.sellmanager.controller; import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream; import javax.annotation.Resource; import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label; import com.cmcc.zysoft.sellmanager.service.SysLBSService;
import com.cmcc.zysoft.sellmanager.util.CMPPSenderUtil; /**
*
* 类说明:
*
* @创建时间 2014-3-17 下午1:52:55
* @创建人: cmzcheng
* @邮箱:cmzcheng@gmail.com
*/
public class ExcelOperate { @Resource
private SysLBSService sysLBSService; public static void main(String[] args) { jxl.Workbook readwb = null;
try { // 构建Workbook对象, 只读Workbook对象 // 直接从本地文件创建Workbook InputStream instream = new FileInputStream("D:/sms.xls"); readwb = Workbook.getWorkbook(instream); // Sheet的下标是从0开始 // 获取第一张Sheet表 Sheet readsheet = readwb.getSheet(0); // 获取Sheet表中所包含的总行数 int rsRows = readsheet.getRows(); // 获取指定单元格的对象引用 for (int i = 0; i < rsRows; i++) {
String mobile= readsheet.getCell(0, i).getContents();
String login_url = readsheet.getCell(1, i).getContents();
String serviceName = readsheet.getCell(2, i).getContents();
sendSms(mobile, login_url, serviceName);
System.out.println(serviceName + " ," + mobile + "," + login_url);
}
//利用已经创建的Excel工作薄,创建新的可写入的Excel工作薄 jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(new File( "d:/短信发送列表.xls"), readwb); //读取第一张工作表 jxl.write.WritableSheet ws = wwb.getSheet(0); //获得第一个单元格对象 jxl.write.WritableCell wc = ws.getWritableCell(0, 0); //判断单元格的类型, 做出相应的转化 if (wc.getType() == CellType.LABEL) { Label l = (Label) wc; l.setString("新姓名"); } //写入Excel对象 wwb.write(); wwb.close(); } catch (Exception e) { e.printStackTrace(); } finally { readwb.close(); } } @SuppressWarnings("static-access")
public static boolean sendSms(String phone, String login_url,
String serviceName) {
boolean ls = getPhoneName(phone.substring(0, 3));
CMPPSenderUtil cmp = new CMPPSenderUtil();
try {
if (ls) {// 如果是中国移动的号码
cmp.sendMsg(phone, getContent(phone, login_url, serviceName));
} else {// 表示的是移网
cmp.sendDifferenceNetMsg(phone,
getContent(phone, login_url, serviceName));
} return true;
} catch (Exception e) {
// TODO: handle exception
return false;
} } /**
*
* @param phone
* phone
* @return String
*/
public static String getContent(String phone, String loginURL,
String qiyeTtitle) {
return "您好!" + qiyeTtitle
+ "系统已于3月15日启用域名访问啦,您单位专有网址为+ loginURL+ " ,登录帐号和密码不变,请去试试吧";
} public static boolean getPhoneName(String phoneName) {
String strings = "134,135,136,137,138,139,150,151,152,157,158,159,187,188,182,147,183,184";
boolean flg = strings.contains(phoneName);
return flg;
} }
写的一个读取本地excel然后发短信的代码,记录下在此
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
读取本地excel发短信的更多相关文章
- 用Python调用华为云API接口发短信
[摘要] 用Python调用华为云API接口实现发短信,当然能给调用发短信接口前提条件是通过企业实名认证,而且有一个通过审核的短信签名,话不多说,showcode #!/usr/bin/python3 ...
- linux下利用GPRS模块发短信、打电话
一.开发环境 内核版本:linux-3.0 开发板:FL2440(nandflash:K9F1G08 128M) GPRS模块:SIM900 二.与发短信和拨号相关的 AT 指 ...
- [stm32] SIM808模块之发短信\GPS\TCP\HTTP研究
SIM8008是四频模块,全球可用.含有TTL电平接口等接口,能够实现发短信.打电话.GPRS传输数据.GPS等功能.[正版资料请找beautifulzzzz·博客园] 一些细节: >> ...
- 单线程与多线程的简单示例(以Windows服务发短信为示例)
单线程示例: public delegate void SM(); SM sm = new SM(() => { while (true) ...
- Android——SMS接收发短信与运行权限
好久没写了,最近学习Android的相关知识,包括UI组件与布局.Activity生命周期等,而这次要讲的是,Broadcast Receiver的相关知识,主要是接收发短信,SmsManager.S ...
- C# 聚合数据借口发短信的使用
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- iOS开发之调用系统打电话发短信接口以及程序内发短信
在本篇博客开头呢,先说一下写本篇的博客的原因吧.目前在做一个小项目,要用到在本应用程序内发验证码给其他用户,怎么在应用内发送短信的具体细节想不大起来了,于是就百度了一下,发现也有关于这方面的博客,点进 ...
- 打电话,发短信,发邮件,app跳转
1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...
- iOS中如何切换到发短信、打电话、发邮件
我们在做APP的时候,难免会遇到需要调用短信,电话等程序的时候.如美团. 当然,这些都只是一些简单的方法就可以实现,但是时间久了也会淡忘,所以想写这边博客.一是为了再捡起来复习一下,另一个相当于留个备 ...
随机推荐
- scjp考试准备 - 4 - 关于数组
好吧这道题我丢脸了,竟然做错了. 如下程序的输出结果是: class Alligator{ public static void main(String[] args){ int[]x[] = {{1 ...
- MATLAB 利用filter函数实现滑动平均滤波
function [ y ] = moving_average( x, win_size ) y1=filter(ones(1,win_size/2+1)/win_size,1,x); y2=fi ...
- win8中如何禁用屏幕旋转的快捷键
程序员通常会使用ctrl+alt+方向键 里编辑代码,特别对于使用eclipse的程序员,更是如此,但是win8却把这一快捷键给占用了,很不爽,如何办,很简单.直接上图: 2.但是发现禁用之后并没有解 ...
- CS小分队第一阶段冲刺站立会议(5月8日)
昨日成果:优化了扫雷游戏,解决了界面随格子数改变却不能缩小的bug,另外改写了程序,能使用户在点下第一个雷时再生成代码,防止第一步踩到地雷. 遇到的困难:主要就是考虑扫雷需不需要有一个存档,这个存档用 ...
- 随机的30道四则运算题(简单的c)
#include <stdio.h>#include <stdlib.h>#include <time.h> int main(void){ int i = 0; ...
- boostrap中lg,md,sm,xs
boostrap中lg,md,sm,xs分别表示多少px? .col-xs- 超小屏幕 手机 (<768px).col-sm- 小屏幕 平板 (≥768px).col-md- 中等屏幕 桌面显示 ...
- python操作sqlite数据库
root@cacti:~/box# cat convert.py #!/usr/bin/env python import sqlite3,time,rrdtool,os def boxstatus( ...
- Careercup - Google面试题 - 5727310284062720
2014-05-06 14:04 题目链接 原题: given an 2D matrix M, is filled either using X or O, you need to find the ...
- Careercup - Google面试题 - 6271724635029504
2014-05-06 13:23 题目链接 原题: Finding a pair of elements from two sorted lists(or array) for which the s ...
- 22、DDMS(转载)
本文是转载,出处为http://www.xuebuyuan.com/1291595.html 如需删除本文,请私信我,谢谢 DDMS DDMS是一款Google* 提供的应用,可作为独立的工具运行,也 ...