首页 \ 问答 \ 从while循环获取一些记录到数组,然后通过电子邮件发送这些记录(Get some records from a while loop to an array, then send these records in an email)

从while循环获取一些记录到数组,然后通过电子邮件发送这些记录(Get some records from a while loop to an array, then send these records in an email)

我有一个while循环:

$users = mysqli_query($con, "SELECT * FROM table");
while($row = mysqli_fetch_array($users)) {          
  if    ($row['column1'] !=  $row['column2']) {
    echo "There is a different between column1 and column2<br />";
  }
}

我想得到column1column2不同的所有记录,并将这些值放入电子邮件中。

电子邮件看起来像这样:

ID     Column1   Column2
1      111       222
4      222       333

我以为我可以用array_push做到这一点,但我没有让它工作。

知道如何完成这项工作吗?


I have a while loop:

$users = mysqli_query($con, "SELECT * FROM table");
while($row = mysqli_fetch_array($users)) {          
  if    ($row['column1'] !=  $row['column2']) {
    echo "There is a different between column1 and column2<br />";
  }
}

I want to get all the records where column1 is different from column2 and get these values into an email.

The email looks like this:

ID     Column1   Column2
1      111       222
4      222       333

I thought I could do this with array_push but I'm not getting it to work.

Any idea how to get this done?


原文:https://stackoverflow.com/questions/29167423
更新时间:2023-07-22 19:07

最满意答案

使用COM绑定调用Unprotect方法。

import win32com.client

excel = win32com.client.Dispatch('Excel.Application')

workbook = excel.Workbooks.open(r'c:\mybook.xls', 'password')

workbook.SaveAs('unencrypted.xls')

SaveAs可以应用新密码。 请参阅: http//msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.saveas%28VS.80%29.aspx


Use the COM bindings to call the Unprotect method.

import win32com.client

excel = win32com.client.Dispatch('Excel.Application')

workbook = excel.Workbooks.open(r'c:\mybook.xls', 'password')

workbook.SaveAs('unencrypted.xls')

SaveAs can apply a new password. See: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.saveas%28VS.80%29.aspx

相关问答

更多
  • 为每个文件添加一个Excel源代码以加入它们的“联合所有”任务,因此如果您的第一个Excel上有20行而第二个上有30行,那么最终会有50行: 要设置源路径和目标路径,只需双击每个任务并设置连接管理器 编辑: 如何在此处读取excel文件的示例 add an Excel source for each of your files an a "union all" task to join them, so if you have 20 rows on your first excel and 30 on t ...
  • 使用COM绑定调用Unprotect方法。 import win32com.client excel = win32com.client.Dispatch('Excel.Application') workbook = excel.Workbooks.open(r'c:\mybook.xls', 'password') workbook.SaveAs('unencrypted.xls') SaveAs可以应用新密码。 请参阅: http : //msdn.microsoft.com/en-us/li ...
  • 你可以试着用这个加载文件在内存中: Stream exportData = new MemoryStream(byte[] fileBuffer); can you try to load the file in memory with this : Stream exportData = new MemoryStream(byte[] fileBuffer);
  • 如果您遇到非托管C ++并且需要直接与Excel通信,则需要COM自动化接口。 请参阅MSDN文章链接文本 如果你想要新的托管互操作的强大功能,我想你可能需要将你的C ++代码包装在一个interop dll中。 If you're stuck with unmanaged C++ and need to communicate directly with Excel you'll need the COM automation interfaces. See the MSDN article link t ...
  • 就像DaDaDom说的那样,Apache POI就是你正在寻找的东西。 你可以从这个页面下载它。 请注意,POI项目不完全独立,您可能需要下载一些额外的库。 按照Apache POI网站上的说明进行操作。 这是你如何使用它: InputStream myxls = new FileInputStream("workbook.xls")); HSSFWorkbook wb = new HSSFWorkbook(myxls); // for *.xlsx use XSSFWorkbook 如果它是一个新文件, ...
  • 您需要的是PGP的COM或ActiveX组件,它解密PGP消息。 似乎有一些关于,例如这个 (这不是推荐,BTW!) 将它安装到您的PC上,然后在Excel VB窗口中通过Tools> References菜单添加项目引用:在列表中找到PGP组件并选择它。 然后,您可以使用它在VBA代码中公开的对象 - 您必须查看它为其公开的COM对象提供的任何文档以及如何使用它们。 干杯 - What you need is a COM or ActiveX component for PGP which decrypt ...
  • 由Andy Khan发现了一个jExcelApi Found one jExcelApi by Andy Khan
  • 您是否尝试将VBA代码保存在“.bas”文件中? 然后,您可以尝试通过Excel interop以编程方式添加代码。 如果这不起作用,为什么不简单地在Workbook_Open事件触发时添加以下代码: Private Sub Workbook_Open() Dim sModulePath As String sModulePath = "path" ThisWorkbook.VBProject.VBComponents.Import Filename:=sModulePath En ...
  • LibXL拥有商业许可和iOS支持199美元(目前)。 它可以在这里下载。 LibXL have a commercial license and iOS support for $199 (currently). It can be downloaded here.

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)