我使用了以下代码但它返回false虽然它应该返回true
string check,zipcode;
zipcode="10001 New York, NY";
check=isalphanumeric(zipcode)
public static Boolean isAlphaNumeric(string strToCheck)
{
Regex rg = new Regex("[^a-zA-Z0-9]");
//if has non AlpahNumeric char, return false, else return true.
return rg.IsMatch(strToCheck) == true ? false : true;
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码,在OpenXML SDK中为该单元格添加一个值和数据类型的单元格:
Cell cell = InsertCellInWorksheet(column, row, worksheetPart);
cell.CellValue = new CellValue(index.ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
Run Code Online (Sandbox Code Playgroud)
对于此单元格,如何在每侧添加边框?我也想在单元格上添加背景颜色.
我有以下但不知道如何将边框添加到单元格:
Borders borders1 = new Borders() { Count = (UInt32Value)1U };
Border border1 = new Border();
LeftBorder leftBorder1 = new LeftBorder();
RightBorder rightBorder1 = new RightBorder();
TopBorder topBorder1 = new TopBorder();
BottomBorder bottomBorder1 = new BottomBorder();
border1.Append(leftBorder1);
border1.Append(rightBorder1);
border1.Append(topBorder1);
border1.Append(bottomBorder1);
borders1.Append(border1);
Run Code Online (Sandbox Code Playgroud)
提前致谢
我正在尝试将openXML电子表格文档作为byte []返回,然后我可以使用它来允许我的MVC将该文件发送给用户.这是我的spreadsheetdocument方法返回字节数组
using (MemoryStream mem = new MemoryStream())
{
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
Create(mem, SpreadsheetDocumentType.Workbook);
// Add a WorkbookPart to the document.
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
// Add a WorksheetPart to the WorkbookPart.
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
// Add Sheets to the Workbook.
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
AppendChild<Sheets>(new Sheets());
SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();
//row start
for (int id = 0; id <= reports.Count(); id++)
{
if (id == 0)
{
Row …Run Code Online (Sandbox Code Playgroud) 尝试获取具有多个级别的对象时,无法获得结果。这是我正在尝试大致执行的操作:
_context.Investors.Where(s => s.Id == userId)
.Include(c => c.Coins) //only want this if some kind of flag is given by the user.
.ThenInclude(ct => ct.CoinType)
.Include(c => c.Bricks) //only want this if some kind of flag is given by the user.
Run Code Online (Sandbox Code Playgroud)
本质上,我会收到很多标志,指示是否应包括对象的一部分。我几乎要工作了。像这样:
_context.Investors.Where(s => s.Id == userId)
.Select(i => new
{
i,
Bricks = (details & GapiInvestorFlags.Bricks) != GapiInvestorFlags.Bricks ? null : i.Bricks,
Offers = (details & GapiInvestorFlags.Offers) != GapiInvestorFlags.Offers ? null : i.Offers,
Coins = (details & GapiInvestorFlags.Coins) != …Run Code Online (Sandbox Code Playgroud) 我正在开发一个由服务器和 Android 应用程序组成的系统,它必须联系所述服务器。在应用程序中,当前可以指定服务器地址,但我们现在希望客户端自动查找本地网络上的服务器以使其更可用。我目前对这个问题的理解是,我可以向本地广播地址发送一条消息255.255.255.255,然后该消息将到达本地网络中的所有IP。到目前为止,我想出了以下内容:
try {
DatagramSocket discoveryBroadcaster = new DatagramSocket();
discoveryBroadcaster.send(new DatagramPacket(msg.getBytes(),msg.getBytes().length,
InetAddress.getByName("255.255.255.255"),8000));
}
catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我们通过 RESTful 接口与服务器进行通信。我希望我们发送的消息是 GET 请求,以便我们可以像其他所有内容一样将服务器上的响应作为端点实现。问题是我知道创建 GET 请求的唯一方法是通过类httpurlconnection,它首先需要一个目标 URL。因此,我的问题是:
我只需要在我的 antd 输入字段中输入数字。但它接受数字和字母。因为我的需求逻辑工作正常,除了字母表。那么我怎么能写一个只接受数字的正则表达式呢?
import React from 'react'
import * as AntD from "antd";
import { Input, Tooltip } from 'antd';
const { Row, Col } = AntD;
function creditCardFormatter(value) {
var v = value.replace(/\s+/g, '').replace(/[^0-9]/gi, '')
var matches = v.match(/\d{4,16}/g);
var match = matches && matches[0] || '';
var parts = [];
for (let i = 0, len = match.length; i < len; i += 4) {
parts.push(match.substring(i, i + 4));
console.log(parts)
console.log(match)}
if (parts.length){
console.log(parts.length)
return parts.join(' ');
} …Run Code Online (Sandbox Code Playgroud) 我想编辑/更改文本框中的Excel工作表中的文本。我遍历了sharedstringtable中的所有条目,但是找不到。
var sharedStringTablePart = spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
foreach (SharedStringItem ss in sharedStringTablePart.SharedStringTable.Elements<SharedStringItem>())
{
if (ss.InnerText == text)
{
//Do somethinhg
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
我正在尝试使用openxml从工作表中删除所有公式。这是我正在尝试的:
internal static void ReplaceFormulaWithValue()
{
var res = _worksheetPart.Worksheet.GetFirstChild<SheetData>().Elements<Row>();
foreach (Row row in _worksheetPart.Worksheet.GetFirstChild<SheetData>().Elements<Row>())
{
foreach (Cell cell in row.Elements<Cell>())
{
if (cell.CellFormula != null &&
cell.CellValue != null)
{
string cellRef = cell.CellReference;
CalculationChainPart calculationChainPart = _spreadSheet.WorkbookPart.CalculationChainPart;
CalculationChain calculationChain = calculationChainPart.CalculationChain;
var calculationCells = calculationChain.Elements<CalculationCell>().ToList();
CalculationCell calculationCell = calculationCells.Where(c => c.CellReference == cellRef).FirstOrDefault();
//CalculationCell calculationCell = calculationChain.Elements<CalculationCell>().Where(c => c.CellReference == cell.CellReference).FirstOrDefault();
string value = cell.CellValue.InnerText;
UpdateCell(cell, DataTypes.String, value);
cell.CellFormula.Remove();
calculationCell.Remove();
}
}
}
SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
打开excel文档时,出现以下错误:
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 您好,我有一个与 绑定的 WPF 数据网格TrulyObservableCollection,每当我尝试通过文本输入编辑单元格时,数据网格单元格在输入每个键后都会失去焦点,
public sealed class TrulyObservableCollection<T> : ObservableCollection<T>
where T : INotifyPropertyChanged
{
public TrulyObservableCollection()
{
CollectionChanged += FullObservableCollectionCollectionChanged;
}
public TrulyObservableCollection(IEnumerable<T> pItems)
: this()
{
foreach (var item in pItems) {
this.Add(item);
}
}
private void FullObservableCollectionCollectionChanged(object sender,
NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null) {
foreach (Object item in e.NewItems) {
((INotifyPropertyChanged)item).PropertyChanged += ItemPropertyChanged;
}
}
if (e.OldItems != null) {
foreach (Object item in e.OldItems) {
((INotifyPropertyChanged)item).PropertyChanged -= ItemPropertyChanged;
}
}
}
private …Run Code Online (Sandbox Code Playgroud) 我有一个包含员工帐户详细信息的xml.我试图用LINQ计算总和.我有以下查询:
var totalSum = (from account in accounts
where account.Status == "active"
select account.Balance).Sum();
Run Code Online (Sandbox Code Playgroud)
我还继续将数据解析为数据库表.当我针对我的xml运行时,我有不同的结果,当我对着我的数据库运行时,我有一个不同的结果.我检查了解析器,并正确解析了所有条目.
我还运行了一个SQL查询来计算Sum,并且它与db中的LINQ查询匹配.真的无法弄清楚问题是什么,因为我的解析器是正确的.